I must stress my usage of GIT (via VS2019 Team Explorer) has so far been fairly basic: 2 users, often working in sequence on the Master
branch. Very happy to be suggested some reading for a deeper introduction to the concepts of GIT.
We wanted to start using GIT through a more business-like workflow. The idea is to keep the Master
for core updates/upgrades, and to fork new branches based on past commits when publishing mini hot fixes: we pick the commit of the last publish, and create a new branch based on this commit; let's we call it HotFix
. We do our fix, commit/publish/push
, and then merge
with the Master
.
So we just started: Yesterday Mike created the HotFix
branch, fixed a bug, committed, published the update, and push
ed the commit to the remote. No merging with the Master was done yet. Today, Bob started Visual Studio, selected the HotFix
branch, did not pull, and started to work on a second bug. Now he tries to push
, but GIT is not happy and says:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes before pushing again.
We understand this is because since he did not pull before starting to work, he is 1 commit behind Mike's/the Remote's version of the same branch. When this happens on the Master
, we typically pull
and merge/resolve any conflicts, and then push
the work. But here, we cannot pull
. There also is a message that says:
The current branch does not track a remote branch.
We are a bit confused, because VS documentation says you need to push the branch so that it tracks the remote, but we cannot push
because we are 1 commit behind the remote and should pull
first, which requires push
ing.. is this a catch 22 situation?
I read here that $ git branch -u origin/dev
will make "a tracking relationship for your current HEAD branch". I also feel that this post describe a similar scenario to ours; however the UX flow described in the most popular answer differs from what we have, I guess because we already have a remote repository, only the specific branch is problematic.
We understand the concepts of GIT and incremental versioning, but we know so little about its subtleties that I am scared of doing something irreversible. Could anyone confirm we are on the right track?
question from:https://stackoverflow.com/questions/66052848/the-current-branch-does-not-track-a-remote-branch