- Download a given pull request:
- Checkout a file from another branch (overwrite file):
- Recover a deleted file
- Compare files from different commits/branches
- Upload local branch to a remote but into a new branch
- Show files changed on each commit
- How to know which tracks each branch
- How to change the remote branch tracking a local branch
- Delete a branch both on local and remote
- Delete a tag both on local and remote
- Download the PR specified by the
ID
into a new branchBRANCHNAME
:$ git fetch origin pull/ID/head:BRANCHNAME
- Switch to the branch:
$ git checkout BRANCHNAME
You are on a branch branch1
and want to overwrite file file
with the contents of the same file in branch branch2
:
$ git checkout branch1 # Go to branch1
$ git checkout branch2 file # Checkout the file from branch2
- Find the last commit that affected the given path. As the file isn't in the HEAD commit, this commit must have deleted it:
git rev-list -n 1 HEAD -- <file_path>
. - Then checkout the version at the commit before, using the caret (^) symbol:
git checkout <deleting_commit>^ -- <file_path>
.
$ git diff branch1 branch2 -- file
$ git push origin local_name:remote_name
$ git log --pretty=oneline --name-status
$ git branch -vv # doubly verbose!
Suppose you are working the local branch A you want the tracking remote to be B:
$ git branch local_branch --set-upstream-to remote/remote_branch
To remove a local branch from your machine:
$ git branch -D my-local-branch
To remove a remote branch from the server:
$ git push origin :{the_remote_branch}
$ git tag -d release01
$ git push origin :refs/tags/release01