5 Tricks For Git You May Not Use Yet (Part 3)


Two final Git tricks that you might find useful. We have two final Git tricks that you might find useful. Please enjoy and feel free to leave your comments below."

Continuing on with our small series of posts about Git and some of the Git commands we use at PhraseApp when working with the powerful SCM. Just like Git, PhraseApp is designed to help you save time and making your life a little easier.

Trick #4: Backporting With Patches Using Git Diff

When handling a flow with a release branch it might be necessary to backport certain changes. This can be easily done with:

followed by applying the patch on the current HEAD:

Afterwards you need to commit the changed files.

Trick #5: Using Pull-Requests And The Power Of The Force

Working with feature-branches can be a hassle. However, if your process or team distributions leads you towards this process, be sure to utilize pull requests on Github. When you push a new branch and visit the project on Github afterwards, Github will ask you whether you want to open a pull-request for the feature branch.

A pull-request is basically a web-annotation for the branch and a signal to the other developers on the project that this particular branch of features wants to become part of the master branch.

This can be helpful for code-reviews or as a documentation for the introduced changes.

When the feature-branch is up-to-date with master – meaning it contains all commits of master and is rebased upon master (all the branch’s commits come after the commits in master in the branch’s history), it can be automatically-merged on Github. If this fails ask the branch’s committers to rebase the master. They should be the best to decide how the new code fits in.

Force-pushing to the feature-branch updates the pull-request as well. So it can be a good idea to squash the commits in a feature branch to a single commit in order to reduce rebasing-pain with master.

Be aware that force pushing to origin/master is generally a bad idea. Especially if you are not alone on a project, since this may actively change the history of the branch.

Usually by improving his or her git-skills a developer using git will save valuable time that could be better spent on programming.

Further Reading

There are a couple of really well-written books on this topic that you should check out. One of my favorites is “Pragmatic Version Control Using Git” by Travis Swicegood.

Read more in our other articles on the topic:

Be sure to subscribe and receive all updates from the PhraseApp blog straight to your inbox. You’ll receive localization best practices, about cultural aspects of breaking into new markets, guides and tutorials for optimizing software translation and other industry insights and information. Don’t miss out!

Also published on Medium.