Decentralized version control system.
When you want to find out which commit first referenced a given string:
git log -S <string to search for> --source --all
This is useful when you want to revert a set of commits, but also when you want to change them before committing again.
git revert -n <commit hashes to revert>
git branch -d $BRANCH_NAME will delete a local branch IFF it’s been merged with the upstream branch (or remote). If you pass in
--force, then it’ll delete it regardless.
git branch -D $BRANCH_NAME is a shorthand for
git branch -d --force $BRANCH_NAME.
git branch -D prefix* doesn’t work (git won’t do the name completion for you). Instead, something like this will work:
git branch | grep "$PREFIX_STRING" | xargs git branch -D
Say you branch off
develop. But you later find out you need to merge it into
master. How do you merge only the commits from
master without including other commits from
As with most things in software, stackoverflow has the answer.
git checkout my_work git rebase --onto master develop my_work
That is, you rebase onto the target branch, from the original branch point, with the branch you want to move.
Submodule are a neat, basic way to manage dependencies.
Adding one is easy
git submodule add SUBMODULE_URL
When you’re not the one who added it, the command to pull down the submodules is less obvious.
git submodule update --init --recursive