Skip to content

Instantly share code, notes, and snippets.

@timglorioso
Last active May 17, 2021 19:36
Show Gist options
  • Save timglorioso/08df83d111f7768266a654dbdc3daad9 to your computer and use it in GitHub Desktop.
Save timglorioso/08df83d111f7768266a654dbdc3daad9 to your computer and use it in GitHub Desktop.
git cheatsheet

Sync your fork with upstream changes. Assumes upstream is a remote with URLs configured.

git fetch upstream
git rebase upstream/<upstream-branch>
git push

Sync your local repository with remote changes. Will rewrite your local history via --rebase.

git pull --rebase <remote> <branch>

Fetch the git history (i.e., .git), but not the repository contents.

git clone --no-checkout <repository>

Fetch a remote branch.

git fetch <remote> <remote-branch>:<new-local-branch>

Reset local branch to match remote branch.

git checkout <local-branch>
git reset --hard <remote>/<remote-branch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment