Skip to content

Latest commit

 

History

History
49 lines (43 loc) · 2.06 KB

README.rdoc

File metadata and controls

49 lines (43 loc) · 2.06 KB

Git Learning Tests

Tests to learn the ins and outs of the Git Distributed Version Control System

This repository is used to make tests with git, branch merging and rebasing, remote tracking, staging and unstaging files, revert commits, rewrite history, squash commits, discard changes from the working directory, etc

Quick Reference:

git reset --hard HEAD^ (or HEAD~1 to undo one commit)
git reset --hard HEAD~n (HEAD~3 to undo 3 commits)
git reset HEAD <file> (to unstage changes - unstage alias)
git checkout -- . (for discarding all changes)
git checkout -- <file> (for discarding changes on a specific file)
git aliases
  co = checkout
  br = branch
  ci = commit
  ft = fetch
  fta = fetch --all
  unstage = reset HEAD
  stash-unapply = !git stash show -p | git apply -R
git remote set-url <remote> <new-url>
git remote show <remote> (for showing remote branches tracking information)
git push <remote> <local_branch>:<remote_branch> (for different names in local and remote branches, use -u to set tracking branches)
git format-patch <base_of_topic_branch>

My Git cheatsheet

git reset --hard HEAD~n (HEAD~3 to undo 3 commits)
git reset HEAD <file> (to unstage changes - unstage alias)
git checkout -- <file> (for discarding changes on a specific file)
git remote show <remote> (for showing remote branches tracking information)
git push <remote> <local_branch>:<remote_branch> (for different names in local and remote branches, use -u to set tracking branches)
git checkout -b <new_branch> <based_on_branch>
git rebase --onto <new_base> <mid_branch> <rebased_branch>
git merge --no-commit --squash <topic_branch>

Notes on learning:

Git difftool and mergetool configured to diffmerge as below:

[diff]
  tool = diffmerge
[difftool "diffmerge"]
  cmd = diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
  tool = diffmerge
[mergetool "diffmerge"]
  cmd = "diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$(if test -f \"$BASE\"; then echo \"$BASE\"; else echo \"$LOCAL\$
  trustExitCode = true

João Soares ©2012