Skip to content

Instantly share code, notes, and snippets.

@shmup
Last active December 15, 2015 15:19
Show Gist options
  • Save shmup/5281071 to your computer and use it in GitHub Desktop.
Save shmup/5281071 to your computer and use it in GitHub Desktop.
delete a remote branch

git push origin :fakebranch

to pull changes from master into my branch (maybe important code changes)

git pull origin

git merge master

push a local branch to a different remote branch

git push remote local_branch:remote_branch

git push remote typo:develop

create a local branch that tracks a remote branch

git fetch

git checkout --track origin/develop

http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git

pull vs fetch

pull automatically merges the commits into the branch you are currently working on, without letting you review them. this could cause conflicts if not closely managed.

fetch does not merge with current branch, and instead stores in a local repository. to integrate, use merge.

http://stackoverflow.com/a/7104747/463678

merge vs rebase

http://stackoverflow.com/questions/804115/git-rebase-vs-git-merge

revert one file to the last commit

git checkout -- filename

git stash

stashes away any changes in current branch since last commit. use git stash apply to restore.

git cherry-pick

scenario: working in feature branch that isnt ready for full merge but has a few commits you want to push to master. copy first 6-7 characters of commit ID's you want, checkout master: git cherry-pick c90fd66

git svn notes

update repo

git svn rebase

commit repo

git svn dcommit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment