Skip to content

Instantly share code, notes, and snippets.

@abhiomkar
Created June 29, 2011 10:51
Show Gist options
  • Select an option

  • Save abhiomkar/1053635 to your computer and use it in GitHub Desktop.

Select an option

Save abhiomkar/1053635 to your computer and use it in GitHub Desktop.
Git Cheat-sheet
## GIT Colors ON
git config color.branch auto
git config color.diff auto
git config color.interactive auto
git config color.status auto
## GIT Default Editor
git config --global core.editor vim
## Undo the Push (Revert the changes on Remote)
# ---------------------------------------------
# Source: http://stackoverflow.com/questions/1270514/undoing-a-git-push/1270608#1270608
# You need to make sure that no other users of this repository are fetching the incorrect changes or trying to build on top of the commits that you want removed because you are about to rewind history.
# Then you need to 'force' push the old reference.
git push -f origin cc4b63bebb6:branch_name
# You may have `receive.denyNonFastForwards` set on the remote repository. If this is the case, then you will get an error which includes the phrase `[remote rejected]`.
# In this scenario, you will have to delete and recreate the branch.
git push origin :branch_name
git push origin cc4b63bebb6:refs/heads/branch_name
# If this doesn't work - perhaps because you have `receive.denyDeletes` set, then you have to have direct access to the repository. In the remote repository, you then have to do something like the following plumbing command.
git update-ref refs/heads/branch_name cc4b63bebb6 83c9191dea8 # old_commit new_commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment