Git on mac adds head stuff
Updating a branch with the main one is done through fetching and rebasing with the origin (or merging but that’s not my thing). $ git abort # This cancels anything in the index Getting up to date $ git wait # This moves staged files out of the index
So let’s say I realised my last commit was complete poppycock and I want to undo all of it and never speak of it ever again: $ git undo # This undoes the last commit Not sure why I ever changed though, git nope is gold. I also had it under git nope for a while. And to remove things from the index entirely, I aliased git checkout. To move things out of the index (the opposite of git add), I have git wait (for git reset HEAD). To undo a commit entirely, I created a git undo alias (short for git reset -soft HEAD^) which deletes the last commit from history but keeps the changes in the index in case I want to do something with them. git reset -soft HEAD^, what the hell is that? So let’s see how I make undoing/redoing things easy. Git’s interface to undo things is unbearable in my opinion. gitconfig (and made all my coworkers do the same): # See: This pushes all branches using the same name locally and on the upstream repository.īecause this is a terrible default value (which has been changed in Git 2.* for safety reasons), I updated the push configuration in my. Problem is Git 1.* uses matching as a default configuration for the push command without arguments. When it comes to pushing, I like to avoid having to type the name of the remote (usually origin) and the name of the branch. $ git cm "Replace a regular expression with a split in the forwarder" I did alias git commit -m into git cm though. I could alias to git a but at this stage it would be more annoying to deal with muscle memory than typing these two extra characters. I didn’t alias the add command because it’s short enough that an alias is not necessarily going to bring me any value. The basics of Git are adding some files to the index, committing the index in history, then pushing the history diff to the remote. To make it easier to move to the master and develop branches (as it can happen quite a lot, especially develop), I created the git com and git cod aliases respectively. I aliased git checkout as git co and git branch as git br: $ git br -D feature/my-old-feature Everything goes through pull-requests against the main branch. At N26, the master branch is the protected release branch, and develop is the main one-also protected. To quickly jump between branches, I created a few aliases. This creates a nice graph with the commits id, message, branch name, etc. Because I like my Git logs to reflect what really happened, I have a git lg that’s short for git log -pretty=oneline -abbrev-commit -graph -decorate. There is git log but that’s a very blend display of the past commits, not too mention unbearable to read. The other thing that’s very important, especially when rebasing is to be able to see what the history looks like.
The command I type the most has to be git status, and given how annoying that word can be, I have git s for short. On macOS, I recommend installing iTerm2 and pimping it to display the branch name as part of the prompt. I quickly realised there is no way to be comfortable with command-line Git in the default OS terminal. If you’re unaware what Git is, I wrote Git, the practical very basis on my brother’s blog where I explain the baby steps in version control. It’s a bit long so here is a table of contents: Including some cool aliases and practices you can borrow right away. After a tweet about how I like Git but find it hard to use, I thought it would be interesting to share how I use it on a daily basis.