Skip to content

Instantly share code, notes, and snippets.

@celsowhite
Last active February 6, 2019 22:20
Show Gist options
  • Save celsowhite/a05e956cb192db4ffc4e8cfb5a396eb8 to your computer and use it in GitHub Desktop.
Save celsowhite/a05e956cb192db4ffc4e8cfb5a396eb8 to your computer and use it in GitHub Desktop.
Helpful Git Tips

Checkout New Branch from previous commit

git checkout -b branchname <sha1-of-commit or HEAD~3>

Rename Remote URL

Mainly used if a remote repository name has changed.

git remote set-url origin {new-url}

Rename Branch

If you are on the branch you want to rename:

git branch -m new-name

If you are on a different branch:

git branch -m old-name new-name

Untrack File

Add the file path to .gitignore.

If the file was already being tracked then: git rm --cached <file>

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