Commands

Archive

Create a zip archive of the master branch:

git archive --format zip --output master.zip master

Pull Request

From How can I check out a GitHub pull request with git?

To fetch a remote PR into your local repo:

git fetch origin pull/$ID/head:$BRANCHNAME

Where $ID is the pull request id and $BRANCHNAME is the name of the new branch that you want to create.

Once you have created the branch, then simply:

git checkout $BRANCHNAME

e.g for https://github.com/sethwebster/ember-cli-new-version/pull/104/:

git clone git@github.com:sethwebster/ember-cli-new-version.git
cd ember-cli-new-version
git fetch origin pull/104/head:read-version-in-service
git checkout read-version-in-service

Rebase (Not Merge)

To rebase (rather than merge):

git checkout your-branch-name
git rebase
# fix the conflicts
git rebase --continue
# continue until all the conflicts are fixed

If you want to abort the rebase:

git rebase --abort

Rebase (Squash)

To merge two or more commits into one:

# find the id of your commit
git log --oneline
# pick your base commit (from the top - and one beyond)
git rebase -i 83dfbe2

See How to squash commits by git

Remove file from the repository but keep it locally

git rm --cached somefile.ext

See Remove file from the repository but keep it locally

Reset or revert a specific file to a specific revision

git checkout abcde file/to/restore

Note

The file will be added to git, so to view the changes, git diff --cached.

Reset or revert a specific file to a specific revision using Git