The admin has told me not to merge develop into my branches before pushing them to remote, and that I should create new branches based on master, that way no code from develop will accidentally get merged into master. OK, that has worked fine for several weeks, but a couple of days ago I accidentally merged develop into one of my branches. That didn't create a big problem for the admin, he just told me not to do it again, but since then I started using "git branch --contains" to make sure.
Problem: When I fetch the remote master and run "git branch --contains", it shows that develop is part of it:
git branch --contains
develop
* master
How can that be possible??
I see 3 possible explanations:
git fetch
git checkout master
git reset --hard origin/master
git clean -f
git pull origin master
So as long as develop is in master I cannot create/push any new branches.
Any idea what's going on?
The problem was my understanding of git branch --contains
. It doesn't list branches contained in the currently checked out branch, but branches which contain it.
So to know if master
contains develop
I should do
git checkout develop
git branch --contains
* develop
So there was no problem after all. As this shows, master
is not part of the list of branches which contain develop
.
While this showed that develop
did contain master
, but that's ok.
git checkout master
git branch --contains
develop
* master