Command | Description |
---|---|
git remote -v |
list the remotes |
git pull --rebase |
rebases your local changes on top of your teammates' without creating a merge commit |
git rebase --interactive |
rewrites commits but gives you a chance to modify them as they are reapplied onto the new base |
Command | Description |
---|---|
git log --all --full-history -- **/thefile.* |
find a file that once existed |
git show <SHA> -- <path-to-file> |
find the version of the file you want, and display |
git checkout <SHA>^ -- <path-to-file> |
restore it into your working copy with |
git log --oneline --no-merges HEAD..<remote>/<branch> |
check which changes you're about to pull |
git log --oneline --no-merges <remote>/<branch>..HEAD |
check which changes you're about to push |
Command | Description |
---|---|
git pull --rebase origin master |
rebase local branch with remote master |
git rebase master −−interactive −−exec=”npm test” |
would generate an interactive rebase plan that invokes npm test after rewriting each commit |
git rebase master -x “npm test” |
non-interactive exec |
git checkout feature/whatever && git difftool -y master... |
show the changes since the branch diverged from master but won't show the changes to master since the branch (ie it only shows the feature branch not changes made to master in the meantime) |
git ls-files --stage |
show staged contents' object name, mode bits and stage number in the output |
git update-index --chmod=+x foo.sh |
changes the index to reflect an executable flag on file foo.sh |
Command | Description |
---|---|
git clean -fxd |
clean the repo back to the point you cloned |
st = status -s
lp = log --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --abbrev-commit
ll = log -n 20 --pretty=format:'%Cred%h%Creset %<(55,trunc)%s %Cgreen(%<(7,trunc)%cr) %C(bold blue)<%<(5,trunc)%an>%Creset' --abbrev-commit
ahead = log --pretty=format:'%Cred%h%Creset %<(55,trunc)%s %Cgreen(%<(7,trunc)%cr) %C(bold blue)<%<(5,trunc)%an>%Creset' --abbrev-commit @{u}..
behind = log --pretty=format:'%Cred%h%Creset %<(55,trunc)%s %Cgreen(%<(7,trunc)%cr) %C(bold blue)<%<(5,trunc)%an>%Creset' --abbrev-commit ..@{u}
unstage = reset --
ff = pull --ff-only
review = rebase -i @{u}
co = checkout
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
-- list branches sorted by last modified