Last active
March 13, 2017 18:24
-
-
Save hickerm/7126408 to your computer and use it in GitHub Desktop.
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
to paste text into the git bash use the keyboard shortcut, Insert | |
//show last 5 commits on one line | |
git log --pretty=oneline --max-count=5 | |
//create a branch and switch to it at same time | |
git checkout -b branchname | |
//resolve conflicts via visual merge tool | |
git mergetool | |
//show last commit on each branch | |
git branch -v | |
//merge branch | |
//check out the branch you wish to merge into and then run the git merge command | |
//this scenario would be working on the bug_29868 branch and it's ready to merge/deploy/test | |
git checkout stg | |
git merge bug_29868 | |
//see which branches are already merged into the branch you’re on | |
//branches on this list without the * in front of them are generally fine to delete with git branch -d | |
//as you've already incorporated their work into another branch, so you’re not going to lose anything | |
git branch --merged | |
//see which branches you haven’t yet merged in | |
//if you try to delete these, it will fail as a safety net, but you can force the deletion with -D | |
git branch --no-merged | |
//delete a local branch | |
git branch -d the_local_branch | |
//fetch a remote branch, creates a local branch that tracks a remote branch | |
git checkout --track origin/the_remote_branch_name | |
//rename a local branch | |
git branch -m <oldname> <newname> | |
//see what you've changed but not yet staged | |
git diff | |
//see what you've staged that will go into your next commit | |
git diff --cache | |
//cherry pick changes | |
//* copy the SHA hash from the commit/branch you want (either something like the first 6 or 7 characters from the bash or the entire thing via github) | |
//* switch to the bracnh you want to insert the commit into | |
//* cherry pick your commit: | |
git cherry-pick c90fd66 | |
//not ideal to do this, should be working/merging branches for more sanity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment