0

Because my dev branch is a sub-branch of master, they don't share the same commitline:

My dev is always a few commits ahead of my master

Here's how I created dev as a sub-branch of master:

git checkout -b dev master

After some minor fixes, my master ended up a few commits ahead of my dev branch. I should have been on my dev branch first, but I didn't realize I was on master until I had already pushed the changes.

To fix that, I did a "git pull" to bring my dev up to speed with master. So far, so good.

My Problem

Now when I push commits to my dev branch, it no longer appears as a sub-branch of master. As you can see, their commitline has now merged:

enter image description here

How do I make dev a sub-branch again?

Maxim Vallee
  • 309
  • 3
  • 9
  • 3
    what does it mean `sub-branch`? Your definition `don't share the same commitline` has no practical meaning. Looks like you misunderstood how git works. Or at least I have no idea what is your problem (if you have one). – Marek R Feb 21 '20 at 15:18
  • @ Marek R I created the dev branch this way "git checkout -b dev master". As you can see, dev was created from master. Essentially, I followed the this workflow: https://stackoverflow.com/questions/4470523/create-a-branch-in-git-from-another-branch – Maxim Vallee Feb 21 '20 at 15:27
  • When you created the dev branch it was based on the commit that master pointed to at this very moment. You could have created based on a tag (pointing at the same commit) or the commit pointed at from master with the same result. It is not possible to make it based on master "forever". You can rebase it however at any time back on master. – Onur Feb 21 '20 at 15:32
  • 3
    The fact that 'dev' was branched from 'master' does not make it in anyway subordinate. There is no such thing as a "sub-branch". – William Pursell Feb 21 '20 at 15:32
  • Do you want the commit with log message "added devMode parameter" to still be in the master branch? Or are you trying to re-write the history of master to remove it? – William Pursell Feb 21 '20 at 15:35
  • 1
    By merging the branches, **in this scenario** it looks like they would have the same history after the merge. Thus it doesn't show as separate branches in the graph visual. I'd bet if you make 2 different commits (1 for each branch) on master and dev, you will see the graph visual diverge again. I don't think you actually have the problem that you think you have though. – LLSv2.0 Feb 21 '20 at 15:39
  • 1
    Also, I highly recommend using a tool like this one (which I swear by for newcomers). https://gmaster.io/ The branch visualization tool will give you a much better understanding of the history than the built in terminal git log --graph – LLSv2.0 Feb 21 '20 at 15:41

0 Answers0