Remote-tracking local branches considered harmful #125
Replies: 2 comments 5 replies
-
FWIW, my approach in Jujutsu is to do something more similar to what Mercurial did work bookmarks. That means that the name identifies the branch across remotes. When you fetch from a remote, the branches from that remote will become local branches in your repo, but the tool also remembers the last-seen state on the remote, i.e. the "remote-tracking branch". It won't show the remote-tracking branch if it points to the same target as the local branch does. If you update a branch, the change will be propagated on future pushed. If the remote updates its branches, the difference (compared to the recorded remote-tracking branch) will be applied to the local branch. That can result in a branch being conflicted (similar to Mercurial's renaming to e.g. The above scheme has worked well for me so far, but I mostly use a single remote. I think I need to think a bit more about what should happen when interacting with multiple remotes that you don't control. Git users won't cooperate with this scheme, so some of them will move the If you have |
Beta Was this translation helpful? Give feedback.
-
A
A
As for visualization, on the line of the branch, we report the "push" remote's status, whether we are ready to push, its pushed, or its out of sync. Highlighting the "push" remote location isn't considered important because the local copy is considered canonical. As alluded to in https://github.com/epage/git-stack/issues/12, we do not currently support any representation of the "pull" remote because we assume the local and remote are in-sync |
Beta Was this translation helpful? Give feedback.
-
From a practical perspective, local branches which track remote branches are very useful. From a conceptual perspective, this is one of the big issues with Git.
There are several interesting types of branches in Git to consider:
git pull
andgit push
synchronize the local and upstream branch.git fetch
to bring the remote-tracking branch up to date.git fetch
).In my opinion, Git doesn't make a strong enough distinction between all of these branches, which greatly confuses newcomers. From A Behavioral Approach to Understanding the Git Experience:
In the upcoming version of
git-branchless
(v0.3.7), we show the remote-tracking version of a branch separately from its local version by default. That is, you'll see e.g.master
andremote origin/master
as two different entries in the smartlog.Picture when they point to the same commit:
Picture when they point to different commits:
It should be a lot easier to understand the difference of the local tracking
master
branch and remote-trackingmaster
once they no longer point to the same commit. Unfortunately, the smartlog view doesn't distinguish between the remote-tracking branchmaster
and the remote branchmaster
itself, but this should still be a step forward.Beta Was this translation helpful? Give feedback.
All reactions