git bisect
(demo repo)
git blame
$ git checkout -b newtitle $ editor README.md $ git commit $ git push -u origin newtitle
This section used to be about creating a stand-alone bare clone to share with others over SSH. This still works, of course, but you'll probably also want to learn GitHub since so many people use it.
Warning: some data is not in saved your git repo. For instance: pull request description/body, code reviews. It may be possible to export this.
-x
, as in git cherry-pick -x COMMIT
git merge
or git rebase
git rebase --interactive
git pull --rebase
git config branch.autosetupmerge always
$ git rebase -i HEAD^^^
$ git rebase master
add -p
followed by commit
$ git commit --interactive
git reflog
# make changes $ git commit -m 'first' # make more changes $ git commit -m 'second' # whoops! blow away 'second' $ git reset --hard HEAD^ # hooray, git still has it $ git reflog $ git reset --hard HEAD@{1}
Note that git merge HEAD@{1}
also works. Good luck with that one.
Further reading:
git stash
$ git stash # or $ git stash save 'WIP almost cracked SHA-512' $ git stash list $ git stash show -p $ git stash pop # or $ git stash drop
git grep
git show
git diff
git send-email
git request-pull
Here we will do some of the same things that we did with github, only we will do them manually to show a bit more of what's going on, and to give you an idea of how to operate outside of GitHub.
Create some more changes but don't commit.$ git diff > foo.patchNow commit it (and more) and then use format-patch to get the patch(es)
$ git format-patch HEAD^ $ git format-patch <hash>^Finally show how you can send email directly with many options
$ git send-email --compose --to jkeating@j2solutions.net --subject "Stuff" HEAD^^
Git request-pull allows you to create a summary of differences in your fork of a project. Very similar to a GitHub pull-request.
$ git request-pull origin/master jlk ansible
git apply
git am
Here is how we can process the patch set. This is also what GitHub is doing, and again we'll see the details of what happens.
Applying someting created with (git) diff is git apply.
Applying something created with git format-patch is git am
signed-off-by can be used to add a layer of record keeping
format-patch is better as it includes more context than pure diff
core.autocrlf
appropriately!