Last active
April 25, 2020 04:03
-
-
Save shinchiro/303b2a235659f78ef4e447f60127ad36 to your computer and use it in GitHub Desktop.
Git's trick
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
1. Clone specific branch | |
git clone --single-branch -b new_branch git_url | |
2. Remove/clean git history log | |
git pull --depth 1 | |
git gc --aggressive --prune=now | |
3. Export commit as patch | |
git format-patch -1 | |
4. Checkout PR 123 to branch called "pr123" | |
git fetch origin pull/123/head:pr123 | |
5. Compare commits in upstream with current branch and create diff | |
git format-patch --ignore-if-in-upstream origin --stdout > commits.patch | |
git format-patch --ignore-if-in-upstream origin -o folder/patch | |
6. Squash all commits in branch to single commit | |
git merge --squash branch | |
7. Updating other branch | |
git pull -r another_remote branch_name | |
8. Rebasing PR on top of master | |
git pull -r origin pull/123/head | |
9. Get quick summary about patches which is not in upstream | |
git log --oneline origin/master..HEAD | |
10. Analyse the diff between two branches. More info: https://stackoverflow.com/a/31939492 , https://stackoverflow.com/a/7256391 | |
git diff --stat --color <original-branch>...<forked-branch> | |
11. Get the diff between two branches AND excluding files/folders | |
git diff --stat --color mingw...master -- . ":(exclude)*/include/*" ":(exclude)*/Makefile*" ":(exclude)*/configure*" | |
12. Get log history for a file/folder | |
git log --oneline -- src/foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment