Shortcuts to recurrent Git commands
git fetch public
git checkout master
git merge public/master
List branch remote
git branch -vv
Checkout from a remote branch
git co -b <local name> upstream/master
Push to a remote upstream branch
git push <remote> <local branch>:<remote branch>
eg:
git push upstream foo:master
Read more here.
git config pull.rebase false # merge (the default strategy) git config pull.rebase true # rebase git config pull.ff only # fast-forward only
The tests
directory is a Git subtree created with the
following commands:
git remote add tests [email protected]:nextflow-io/tests.git
git subtree add --squash --prefix=tests/ tests integration
To pull changes from the tests repo use this command:
git subtree pull --squash --prefix=tests/ tests integration
To push changes to the tests repo use this command:
git subtree push --prefix=tests/ tests integration
Read more here.
git stash list
git stash pop
git stash pop stash@{1}
git showtool stash@{0}
git stash drop
git stash drop stash@{1}
git stash clear
git diff stash
git diff stash@{1} [other]
git log --source --all -S <whatever>
git reset --hard HEAD@{1}
Read more https://stackoverflow.com/a/11722640/395921
To sign Git commits with a GPG key on Mac use GPG Suite, import your key, then:
git config --global gpg.program /usr/local/MacGPG2/bin/gpg2
git config --global user.signingkey <your key>
git config --global commit.gpgsign true
git config --global format.signoff true ## TO AVOID TO SPECIFY -S option each time
Read more: https://gist.github.com/danieleggert/b029d44d4a54b328c0bac65d46ba4c65
https://stackoverflow.com/questions/4515580/how-do-i-remove-the-old-history-from-a-git-repository
git fetch origin master:master
Use git fetch && git rebase
Lines added/removed/changed (read more)
git log --shortstat --since "1 year ago" --until "1 week ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
Commits in a period
git rev-list --count HEAD --since=“May 18 2020” --before=“May 18 2021" --all
git diff <tag1> <tag2> -- '<some glob>'
For example:
git difftool v21.01.0-edge v21.02.0-edge -- '**/MANIFEST.MF'
git grep "string/regexp" $(git rev-list --all)
https://stackoverflow.com/a/7151411/395921
git tag --contains <commit id>
git ll --since="last 6 month" | sed 's/.*<\(.*\)>/\1/g' | sort | uniq
git for-each-ref --format="%(refname:short) | %(creatordate)" "refs/tags/*"
git log --shortstat --author "paolo.ditommaso" --since "1 years ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
More here: https://gist.github.com/Xeoncross/4020489
for x in `git tag | grep -- <PATTERN>`; do gh release delete -y $x; git push origin :$x; git tag -d $x; done
gh pr checkout 5042
git commit -am "my changes"
git push
This depends on the check box being ticked by the end user to allow this (it is by default) and it not coming from an organisation's fork.