Skip to content

Instantly share code, notes, and snippets.

@scott-joe
Last active June 21, 2016 17:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scott-joe/3a6eae93f6fd2a19e53c to your computer and use it in GitHub Desktop.
Save scott-joe/3a6eae93f6fd2a19e53c to your computer and use it in GitHub Desktop.

###Create and checkout a new branch git checkout -b [branchName]

###Checkout a remote branch git checkout -b [localBranchName] origin/[remoteBranchName]

###Push local branch to remote git push -u origin [branchName]

###Delete remote branch git push origin --delete [branchName]

git push origin :[branchName]

###Prune local branches git remote prune origin

###Various resets git reset --soft HEAD^

git reset --hard HEAD

git reset --hard origin/master

###Push non-master branch to Heroku git push heroku [branchName]:master

git push heroku +HEAD:master

###Set a Heroku remote to an existing repo heroku git:remote -a [heroku app name]

###fix a local commit git commit -m "Something terribly misguided" git reset --soft HEAD~ << edit files as necessary >> git add [yourFiles] git commit -C ORIG_HEAD

###Rename branch locally and remote git branch -m old_branch [newBranchName] git push origin :[oldBranchName] git push --set-upstream origin [newBranchName]

###Push both commits and annotated tags git push --follow-tags

###Checkout latest tag git checkout $(git describe --tags git rev-list --tags --max-count=1)

###Remove a remote tag git tag -d [tagName] git push origin :refs/tags/[tagName]

@ne8il
Copy link

ne8il commented Jun 21, 2016

checking out a remote branch - if you want localBranchName to be the same as remoteBranchName you can just run git checkout remoteBranchName and it will create the local branch & set it to track the remote

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