Last active
May 31, 2017 04:42
-
-
Save KomanRudden/67569708c079667e2119 to your computer and use it in GitHub Desktop.
Git commands - add, commit, merge, diff, difftool, stash etc
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
| git init - [initializes project as a git managed project] | |
| git ls-file - [list all tracked files] | |
| git add . - [adds everything in project to git staging area] | |
| git commit -am "Comment" - [adds and commits all changed files to staging area] | |
| git pull origin master - [updates local branch with changes from repository] | |
| git push origin master - [push local changes to repository] | |
| git branch - [lists all local branches] | |
| git checkout -b branchName - [switch to branch, -b creates the branch] | |
| git merge my-new-branch - [merges my-new-branch into current branch] | |
| git branch -d my-new-branch - [delete branch] | |
| git cherry-pick 96ef75b - [moves all commits from chosen branch to current branch] | |
| git status - [list the status of the current branch, added/modified/commits files] | |
| git stash save [save is default so can be excluded] | |
| git stash apply - [set master branch back to normal after stashing] | |
| git stash drop - [remove stashed branch] | |
| git stash pop = [pop does an 'apply' and 'drop'] | |
| git stash save "Stash One" - [use 'save' with comment to create multiple stashes] | |
| git stash list - [list all stashes] | |
| git stash show stash@{2} - [stash@{2} will show changes in this stashed branch] | |
| git stash apply stash@{2} - [brings stashed branch at this index to master] | |
| git stash drop stash@{2} - [remove stashed branch at index] | |
| git stash clear - [clear all stashes] | |
| git stash -u - [create stash with all added/modified/committed files] | |
| git stash branch my-new-branch - [uses stashed master branch to create new branch, switches to it and drops stashed branch] | |
| git log --oneline --decorate --graph --all - [git history] | |
| git tag myTag - [tag current branch] | |
| git tag --list - [list all tags] | |
| git tag --delete myTag - [delete tag] | |
| git tag -a v-1.0 - [creates annotated tag] | |
| git show v-1.0 - [show tag] | |
| git diff/difftool v-1.0 v1.1 - [shows differences between tags/branches] | |
| To tag specific commit | |
| git log --oneline --decorate --graph --all - [git history] | |
| git tag -a v-0.9-beta 96ef75b - [as an example use the commit key {96ef75b} you want to tag. This can be retrieved from the log command] | |
| git tag -a v-0.9-beta -f 96ef75a - [changes the above tag to the new commit reference by force -f] | |
| git push origin v-0.9-beta - [pushes tag to repository] | |
| git push origin master --tags - [pushes all tags to repository] | |
| git push origin:v-0.9-beta - [delete tag on remote repository] | |
| To change remote url username | |
| git remote -v - gives pull & fetch remote url | |
| git remote set-url origin http://<USERNAME>@<URL>/<folder>/<project>.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment