Git

How to Change Git Branch Name

A quick one. Here’s how to change your git branch name: If you want to rename of your current local branch: git branch -m new-branch-name If you want to change the name of a different local branch git branch -m old-branch new-branch-name That’s it. Bye.

Set Default Git Push Behaviour

I tend to forget that I have to specify the current branch name when pushing it to a remote. For example: $~ git push or like this $~ git push -u origin Either way, these commands tend to fail when I haven’t yet set the upstream branch. git will return an error similar like this: fatal: The current branch develop has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin <INSERT BRANCH NAME HERE> To avoid this, I have to set the upstream branch name explicitly first before pushing it to the remote repository.

Diff So Fancy

I find it quite hard to make sense of the output from git diff. Let’s just say that it is somewhat off-putting. diff-so-fancy is an open source project to solve this problem and help make your diff much less uglier. Installation There are a lot of ways to install it but I prefer to install all my tools with Brew. So run the following in your terminal: $~ brew install diff-so-fancy Configuration To use diff-so-fancy, you have to set it up globally.

Viewing Diff Since Latest Git Pull

To view the changes between your latest git pull $~ git pull origin $~ git diff @{1}.. @{n} means the n-th previous value of HEAD. You can refer the official docs on reflog Shortnames for more. p/s: I am currently trying to dissociate myself from becoming too dependent on SourceTree for daily git operations.