git Tutorials

  • By
    Git Undo Last Commit

    I'm a massive fan of git; it's super powerful and easy to use, especially when it comes to branching.  The biggest sin I commit when using git is adding files and then committing them...to master branch instead of a feature branch.  Oops.  Certainly don't want that. If you've done a git...

  • By
    git: Delete All Branches but Master

    Maintenance is incredibly important in any project, but if you want to take your professionalism to the next level, you should keep your git environment in shape.  Unfortunately I'm not that guy -- I leave git branches laying around, even after they've been merged into master.

  • By
    Sort git Branches by Date

    I'll be first person to admit I don't do as much git repository maintenance as I should.  I rarely delete branches which have been merged, so a git branch execution shows me a mile-long list of branches that likely aren't relevant.  The best way to find branches I've recently...

  • By
    How to Batch Update Git Commit Messages

    At Mozilla we're mostly strict about receiving contributions via git/GitHub.  Aside from requiring tests and enforcing code quality, one basic of submitting a commit (or several) is that the commit message begins with "bug #######", which is a reference to its Bugzilla bug.  The message requirement makes sense...

  • By
    Get the Git Commit ID via Command Line

    I know just enough git to be dangerous.  I'm not doing advanced bisecting but I can stash, rebase, and reset with the best of them.  One new trick I learned from my boss, Luke Crouch, saves me loads of time:  getting the commit ID via command...

  • By
    Using git reflog to Fix Rebase Problems

    My git jedi skills aren't top class yet but I'm learning how to use the force.  I recently rebased  a pull request, only to find that it added about two dozen more commits, thus my branch was hosed.  After a bit of research, I found git...

  • By
    Reset a Branch to Remote State with git

    Every once in a while I accidentally hose my repository's master branch by merging or committing something I shouldn't.  And then on rare occasion I push that to my remote and then things get all sorts of messed up.  Every PR from that point on has...

  • By
    Delete Merged Branches with git

    It's common courtesy to keep your git branch list clean, especially when colleagues need to fetch your remote branches.  I'm a bit of a ... offender, when it comes to maintaining my git branch list.  My colleague John Karahalis is not, however, and he...

  • By
    Update Submodules with Git

    Git submodules seem to confuse people and I can probably count myself in that group of people that are confused.  Their code is kind of part of the codebase, kind of isn't.  Pulling the latest code from the overall project doesn't pull the updated submodule code...

  • By
    Git Hooks and CSS Preprocessors

    For one of my recent projects, I've decided to use Stylus.  I'm accustomed to using Sass but that would require adding Ruby to our stack -- Stylus is Node.js-based, and since I'm already using Node.js for a few other tasks, I thought I'd give Stylus a try.