I currently have two versions of my software in two separate branches. One version has major changes (renamed some folders, renamed some files, removed a lot of files).
I wish to be able to work on both versions - e.g. do a bugfix in master, push it to origin, maybe merge it into the other branch.
I just tried to do this, and got a bit confused. I did the bug fix in master, and pushed it. I pulled master into the other branch folder. This also seemed to merge. I pushed the result.
Now, if I make another change in the master folder, and try to push all branches, I get complaints "Updates were rejected because a pushed branch tip is behind its remote counterpart" relating to the other branch.
I then tried to pull the other branch into my master folder, but that did a horrible merge, and I ended up with the wrong branch. I think I have recovered from that, but I still can't push from my master folder.
Obviously I am misunderstanding the correct way of working with TortoiseGit, can anyone advise me how I should be proceeding?
Results of git branch -vv
in master folder:
CodeFirst 3b4d37b [origin/CodeFirst] Show 25 entries in DataTables if the screen is big enough.
CodeFirstWebFramework be03722 Added DocumentMemo to report fields.
SilverstreamMerge 778b791 default.js merge
* master 6c1254c [origin/master] Prevent Download button appearing twice in reports.
in branch (CodeFirstWebFramework) folder
* CodeFirstWebFramework 08b9117 Merge branch 'master' of //router/var/svn/AccountServer into CodeFirstWebFramework
master b7994b3 [origin/master: behind 2] Validate Schedule.RepeatFrequency
in origin (upstream repo on another machine)
CodeFirst 3b4d37b Show 25 entries in DataTables if the screen is big enough.
CodeFirstWebFramework 08b9117 Merge branch 'master' of //router/var/svn/AccountServer into CodeFirstWebFramework
SilverstreamMerge 778b791 default.js merge
* master 6c1254c Prevent Download button appearing twice in reports.
I think I am (incorrectly) expecting the pull
command to copy all revisions of all branches from the upstream repo into the local repo. Is there a command to do this?
It sounds like you have two clones of the repo - one checked out to master
and one checked out to some_branch
. That is the more "obvious" way to keep two branches around locally, and there's not necessarily anything wrong with it, but it does mean you have two local sets of branch refs.
If that's the case, you might want to consider git work-tree
as an option. With this you could attach a second working tree to a single local repo, so each tree could be checked out to a different branch without duplicating other aspects of the repository (like the ref list). This could make it simpler to keep everything in sync.
As far as what happened in your situation... it doesn't seem obvious to me; knowing the exact commands you used might help. In general I can say that when the push
fails with that error message, a pull
might help (or, if you're worried about doing that without knowing why first, a fetch
and then examine the differences between the local and remote ref for each branch).