DEV Community

Discussion on: A day in the life for you and git...

Collapse
 
joshuatz profile image
Joshua Tzucker

Mostly the basics, as others are saying. Add, commit, push, merge. Occasionally I'll have a legitimate reason to use cherry-pick, which always feels fun to use for some reason.

Even when it is just myself working on something, I try to avoid commands that "rewrite history", so I don't get in the habit of using them.

Things I've been trying to do more of lately:

  • Branching
    • Keeps things clean and there is "no cost"
    • Trying to do this more as opposed to stashing
  • Using tags
  • Better commit messages

A neat "trick" I recently learned is how to merge branches without switching to them. Not really needed often, but feels cool to use:

git fetch . {localBranchA}:{localBranchToMergeAInto}

Essentially you're saying fetch . (as an alias for local), get the head / latest commit of {localBranchA}, and then fast-forward {localBranchToMergeAInto} to point to it. See this for details.