git merge-base velocity_msync master
git status git diff HEAD --name-only git diff --staged -M
- diff of our most recent commit, which we can refer to using the HEAD pointer git diff HEAD git diff --staged
git log --oneline --decorate git log --oneline --decorate --graph --all git log --oneline git log -1 git log --stat git log -p git log -S function_name
- Search a Git repository by commit message git log --grep='8044'
https://stackoverflow.com/questions/37219/how-do-you-remove-a-specific-revision-in-the-git-history git rebase --onto ^ git rebase -i
git config -l git config --get remote.origin.url
- find changes in file g log --follow -U0 -S "if json_dict['role'] in ('find-me'" lib/file.py g log --follow --oneline -U0 --since=1.month -m lib/file.py
g log --follow -U0 -S "if json_dict['role'] in ('find-me'" lib/file.py g log --follow --oneline -U0 --since=1.month -m lib/file.py
g log --follow -U0 -S "value = cat.availableOptions.peek()[0];" lib/file.py
- pull PR: https://help.github.com/articles/checking-out-pull-requests-locally/
- get pr changes directly from PR: git fetch origin pull/ID/head:BRANCHNAME
git diff file against its last change: git log -p [--follow] [-1]
git describe --tags git rev-parse HEAD
git show f2cd76d19f8371a27711728e1a21f67be3440371 git branch --contains f2cd76d19f8371a27711728e1a21f67be3440371
show local branches: git branch git branch -vv
change tracking branch git branch --set-upstream-to=origin/master
list branches: git branch --remote --list git branch -a git branch -r git remote show origin git remote -v git ls-remote
- Add remote git remote add upstream-foo https://github.com/user/repo.git
-Verify remote git remote -v
-
Update remote branch list git fetch upstream
-
Local branch and want to set it to a remote branch you just pulled down, use -u or --set-upstream-to option to git branch to explicitly set it at any time. git branch -u origin/serverfix
-
You can switch branches using: git checkout
-To check out a particular commit: git checkout
-Switch to a different commit and delete history git checkout --hard
-
Create and checkout new branch tracking the upstream/master remote git checkout -b mybranch upstream/master
-
Files can be changed back to how they were at the last commit: (That will reset foo.txt to HEAD - revert local changes) -- basically means: treat every argument after this point as a file name. git checkout -- foo.txt git checkout -- . git checkout HEAD -- my-file.txt
-
Pull from remote git repository and override the changes in my local repository: git fetch origin git reset --hard origin/master
git reset -- will unstage any staged changes for the given file(s). git checkout -- will reset unstaged file
-
You want to nuke last commit and never see it again. You do this: git reset --hard HEAD~1
-
Rename current branch
-
https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/ git branch -m new-name
-Delete branch matching name g branch | grep branch-name-to-find | xargs git branch -D
-
Undo git add git reset
-
Immediately undo a git rebase
-
https://stackoverflow.com/questions/134882/undoing-a-git-rebase git reset --hard ORIG_HEAD
-
Unstage files by using the git reset command. git reset octofamily/octodog.txt
-
undo git pull git reset --keep HEAD@{1}
-Undo local commit (not added to remote repo and keep changes): git reset HEAD^ git reset HEAD~
-Undo local commit (not added to remote repo and loose changes): git reset HEAD^ --hard
-
Clean up fork and update from master git remote add upstream /url/to/original/repo git fetch upstream git checkout master git reset --hard upstream/master
git push origin master --force -
local branch had a different name than the remote branch
-
https://penandpants.com/2013/02/07/git-pushing-to-a-remote-branch-with-a-different-name/ g push upstream :
git mv source dest git rm '*.txt'
- Create branch from someone else: git fetch [email protected]:/.git :
git pull = fetch + merge git pull --rebase = fetch + rebase g pull upstream master --rebase
Update the local master with upstream, or other remote git pull upstream master git push origin master
-
Set tracking information on my_branch git branch --set-upstream-to=/ my_branch
-
(To keep your branch up to date by pulling from upstream and pushing to your branch remote.) git pull --rebase git push origin mybranch
-
Keeping a fork up to date - Updating your fork from original repo to keep up with their changes: git pull upstream master git push
-- add remote git remote add [email protected]:/.git