DEV Community

Lukas Gaucas
Lukas Gaucas

Posted on • Edited on

Git : feature-branch is nth commits behind

The more I work with Git version control , the more I want to write a book from scratch that would be easy to read, that would include maintainable (up-to-date) link to real life examples, including many of developers experience in one precise volume – I already have a vision how it would look like, although it would take time to write one as I am still learning the git fundamentals, not mentioning some of its boring intrinsic parts of the git ...

However, in this post I'd really like share one small issue I've dealt recently with ; consider we worked for a while on feature-branch that remotely (I said not locally, but remotely !) was merged to remote base branch named develop (or main, master – whichever suits your imagination best) : by convention any default merge action is commit action as well – remote develop becomes -ahead, feature-branch becomes -behind (keep in mind it could be a case of -ahead & -behind mixture), which would subsequently make aforementioned remote feature-branch stay N-th of commits -behind (prerequisite : to state that some branch is -ahead or -behind your local copy of feature-branch must be [pre-]tracked with remote one) . In my case it was both -ahead & -behind remotely . Ignore the -ahead part whereas we interested in -behind part only : -ahead part basically says that you made couple of commits ahead, but you have not yet decided to merge it to base branch remotely .

Feature-branch is -behind n-th of commits [solution]

Prerequisites : The solution suggested assumes you are using GitHub Desktop

Instead of two step process i.e. pulling remote develop to update things locally & then merge local develop to the local copy of remote feature-branch, just do one step process what is called "Update from ..." (in my case it was Update from develop) or Ctrl + Shift + P on GitHub Desktop respectively . This action would remove n-th commits -behind message on your GitHub account for feature-branch or any relevant name of your feature-branch .

Top comments (0)