Created
February 21, 2015 14:38
-
-
Save miekg/b8fbbdf58403688bf149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GIT HOWTO | |
## Partially Apply Pull Request | |
#. git checkout -b other-repo-master master | |
#. git pull https://github.com/other-repo/my-repo-name.git master | |
#. git checkout master | |
#. git cherry-pick COMMIT_HASH | |
## Fetch pull request | |
#. git fetch https://github.com/other-repo/my-repo-name.git remote-branch:local-branch | |
## Pulling remote branch | |
#. git pull | |
3. git co -b local-branch origin/remote-branch | |
## Cherry-pick with no commit | |
#. git cherry-pick -n COMMIT_HASH | |
## Merging | |
#. Keeping ours: `git checkout --ours FILE` | |
#. Keeping theirs: `git checkout --theirs FILE` | |
#. Stopping a botched merge: `git reset --merge` or `git merge --abort` | |
## Merging with vim | |
#. Start `git mergetool` and do your thing. | |
#. Choose the following (diff get) | |
* diffg RE (REmote) | |
* diffg BA (BAse) | |
* diffg LO (LOcal) | |
# Keep track of forked repository | |
#. git clone [email protected]:miekg/REPO.git | |
#. git remote add upstream [email protected]:USER/REPO.git | |
And then: | |
#. git fetch upstream | |
#. git rebase upstream/master | |
# Rebasing a branch (with possible outstanding pull request) | |
The same process basically. | |
# Find deleted filed | |
#. `git rev-list -n 1 HEAD -- <file_path>`. | |
#. Then checkout the version at the commit before. `git checkout <deleting_commit>^ -- <file_path>`. Or in one command, if $file is the file in question. | |
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file" | |
# Amend commit | |
#. git commit --amend -m "New commit message" | |
# Branch from commit | |
#. git checkout -b BRANCH COMMIT_HASH | |
# Delete remote branches | |
git push origin --delete BRANCH | |
# Checkout pull request | |
This is for <http://github.com> specifically. Add this to the section | |
`[remote "origin"]`: | |
fetch = +refs/pull/*/head:refs/remotes/origin/pr/* | |
Then you can checkout specific pull requests like: | |
#. `git fetch origin` | |
#. `git checkout pr/999` | |
# Remove nothave | |
git clean [-fr] . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment