Skip to content

Instantly share code, notes, and snippets.

@rajasgs
Last active June 26, 2019 13:21
Show Gist options
  • Save rajasgs/5099d904ec53c8fdfd97308c153d873a to your computer and use it in GitHub Desktop.
Save rajasgs/5099d904ec53c8fdfd97308c153d873a to your computer and use it in GitHub Desktop.
#
get all commits
git rev-list --all --pretty=oneline
https://stackoverflow.com/questions/1314950/git-get-all-commits-and-blobs-they-created
#
how to cherry pick
git checkout p (target branch)
git cherry-pick <commit_id>
#
Check diff
https://stackoverflow.com/questions/436362/how-to-diff-a-commit-with-its-parent/449128#449128
#
How to find the parent branch?
git parent
https://stackoverflow.com/questions/3161204/find-the-parent-branch-of-a-git-branch
#
When did I create a branch?
git reflog --date=local
git reflog --date=local feat-feature-endpoint-p
https://stackoverflow.com/questions/2255416/how-to-determine-when-a-git-branch-was-created
#
Create a branch from another branch
git checkout -b myfeature dev
https://stackoverflow.com/questions/4470523/create-a-branch-in-git-from-another-branch
#
How to rename a branch name?
https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch
#
Git diff and apply
git diff new-feature..new-feature2 | git apply -
#
git parent
- is buggy
#
Find the parent branch: (buggy as well)
git for-each-ref --format='%(refname:short)' refs/heads/* | while read b; do if r=$(git config --get branch.$b.remote); then m=$(git config --get branch.$b.merge); echo "$b -> $r/${m##*/}"; fi; done
https://blog.liplex.de/git-show-parent-branch/
#
Git Rebase
https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase
#
git bi-sect
https://git-scm.com/docs/git-bisect
#
Git rebase manual vs Git rebase interactive
#
Git rebase vs git merge
https://stackoverflow.com/questions/804115/when-do-you-use-git-rebase-instead-of-git-merge
#
(HEAD detached from refs/heads/feat-product-apply-permission-K20-1382-new)
Not sure what does it mean
https://loekvandenouweland.com/content/head-detached-from-origin-master.html
#
When should I git pull rebase
https://stackoverflow.com/questions/2472254/when-should-i-use-git-pull-rebase
#
merge vs pull
git pull origin master
is same as
git fetch origin
git merge origin/master
https://stackoverflow.com/questions/21756614/difference-between-git-merge-origin-master-and-git-pull
#
Show which files have been changed from another branch
git diff --name-status another_branch
git diff --name-status feat-product-apply-permission-K20-1382-latest
git diff --name-status p
https://stackoverflow.com/questions/822811/showing-which-files-have-changed-between-two-revisions
#
delete a branch
git branch -D branch_name
https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely
#
Git stash
git stash list
will list all stashes
https://git-scm.com/docs/git-stash
#
Show git username
git config user.name
git config --list
https://alvinalexander.com/git/git-show-change-username-email-address
#
View file in another branch
https://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches
#
Undo pushed commits
https://stackoverflow.com/questions/22682870/git-undo-pushed-commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment