Last active
August 8, 2016 14:57
-
-
Save skarra/9710892 to your computer and use it in GitHub Desktop.
Commonly used git commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Branch manipulation commands | |
git checkout -b newbranch # create a new branch | |
git push -u origin newbranch # Push the branch to remote origin | |
git branch --track branch-name origin/branch-name # start tracking new remote branch | |
git checkout master | |
git merge newbranch # merge branch to master | |
git rebase master newbrach # bring newbranch uptodate with changes in master | |
git branch -d newbranch # delete branch | |
git push origin :newbranch # deete branch from origin | |
# Find all commits by one author | |
git log --author="Sriram" --pretty=one | |
## Generating and applying patches | |
# First a style that creates and applies patches in format generally sent via email | |
git format-patch -1 98e75549 # writes a patch file for that sha1 | |
git apply --stat file.patch # Show stats on what will happen if patch is applied | |
git apply --check file.patch # Check for some errors | |
git am < file.patch # Show stats on what will happen if patch is applied | |
## Diff between master and a branch | |
git log master..branch | |
git diff master..branch > changes.diff | |
git apply changes.diff # apply the changes to another local branch | |
git diff --name-status master..branch # only print out names of files changed | |
## Misc | |
git ls-files --others -i --exclude-standard # List all the ignored / untracked files | |
git branch -m <newname> # Rename the current branch in local repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment