Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 980 Bytes

File metadata and controls

55 lines (40 loc) · 980 Bytes

Git commands

Delete a remote branch as well as its local counterpart

$ git push --delete <remote_name> <branch_name>
$ git branch -d <branch_name>

Compare a local branch with a remote branch

$ git diff <local branch> <remote>/<remote branch>

Note: This assumes you have a local branch that tracks a remote one, and your information is up to date.

Checkout a local branch to track a remote

$ git checkout -b <branch_name>

Then:

$ git branch --set-upstream-to <remote_name> <branch_name>

or

$ git push -u <remote_name> <branch_name>

or

git push -u origin HEAD

Update a local branch with remote information

$ git fetch <remote_name> <branch_name>

Update a forked branch

Set upstream to the original that was forked:

$ git remote add upstream

Fetch data (git fetch fetches from origin by default)

$ git fetch upstream