slides url: https://sudoers.utdallas.edu/slides/git-for-mere-mortals.html

Git For Mere Mortals

Host: OpenUTD

Speaker: C. Michael Murphey

Contact: michael@murphey.org

Here's a few small tips I've picked up along the way

git stash is your friend

git stash save "Refactor the thing"

git stash list

git stash apply

git stash push

Have an excessive number of commits in a pull request?

Happens to the best of us...

git merge --squash

Note: this creates a completely new commit!!

While we're at it, let's talk about merges

git merge --ff-only # my favorite :)

git merge --ff # default

git merge --no-ff

I messed up! What do I do?

How much do you hate your changes?

git reset commitsha

git reset HEAD^1

git reset HEAD^1 --soft

git reset HEAD^1 --hard

The nuclear option

git clean -dfx

Just a single file?

git checkout file.txt

git checkout -- file-with-same-name-as-branch

What does git checkout - do?

My pull request for my feature branch has merge conflicts

git stash save "Any changes I might have in progress"

git rebase master

Resolve merge conflicts

git rebase --continue

Note: This replaces a commit!!

Amending commits

git commit --amend

You get to change the contents of the commit and/or change the commit message

Note: This replaces a commit!!

It's time to have "The Talk"

Rewriting history is dangerous

Some people think it's wrong

Never do it on a branch that's not yours

Help? My push is being rejected after I replaced a commit?

Use git push --force-with-lease

What's the difference between --force and --force-with-lease

--force-with-lease is safer

It ensures that the commits on the server are what we expect

.git/info/exclude

You can edit .git/info/exclude if you want to ignore new files but don't want to edit .gitignore

Problem: Anyone can commit as anyone

All you have to do is change user.name and user.email

git-blame-someone-else makes trolling easy

Solution: GPG sign commits

GPG signatures for commits are built into git

Many sites like GitHub now show GPG signatures

Configure git for use with GPG

git config --global user.signingkey KEYIDHERE

Now, you can sign your commits!

git commit -S

Profit!

git log --show-signature

Add your public key to your GitHub account and verify signatures in the GitHub UI

Want to be even more of a commit snob?

Use imperative tense

"Do the thing" instead of "I did the thing"

Hub

hub clone caffeine-overload/bandinchina

hub fetch origin,upstream

hub pull-request

Thank You

Xi Jinping looks like Winnie the Pooh