Skip to content

Instantly share code, notes, and snippets.

@el22or
Last active June 6, 2019 09:02
Show Gist options
  • Save el22or/8d232b6af53c25e314d3 to your computer and use it in GitHub Desktop.
Save el22or/8d232b6af53c25e314d3 to your computer and use it in GitHub Desktop.

Git notes

Remotes

Working with remotes

  • Show remotes
git remote
git remote show upstream

Clone and rename remote to upstream

git clone -o upstream <repository url>

Rename remote

git remote rename origin upstream

Add new remote

git remote add <remote name> <repository url>

Fetch latest changes from source repository

git fetch upstream

Merge / into current branch (master)

git merge upstream/master

Push to forked repository

git push origin master

Reset

Remove all local UNCOMMITTED changes

git reset --hard

Remove all local COMMITTED changes (back to upstream) which are still not pushed to the remote repo

git reset --hard @{u}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment