I seem to have a misunderstanding about branches and remotes. In a tabbed column on the left I see several blue branches which I have been told are my local working branches. I was working on branch bugFix_FFT, which I had just committed and pushed to origin.
Further down there are grey branches under Remotes including releaseV4.x. which I need to merge into my branch. I did not have a working copy of releaseV4.x and was about to checkout a new branch. However my co-worker said I must first perform a fetch to update releaseV4.x before I created a branch from it. I thought that the branches under remote would already be up to date since they are in the bare repository but he said that the grey releaseV4.x was what my "view" thought was the current version and needed to be updated with a fetch.
So was the fetch necessary?
Short answer: yes.
Explanation: Branches are just lightweight pointers to commits. Each time you fetch, all new commits in the repository are added to your local repository (regardless of whether they are part of any of your local branches), and your local record is updated regarding which commits the remote branches are pointing to.
This is one of the concepts that is completely different between Git/Hg vs centralized versioning like SVN. When you checkout a remote branch to your working copy in Git/Hg (making a local branch in the process), your repo does NOT need to access the remote to download the commits for that branch, because they are already in your local repo.
Thanks, but still not quite clear.
You stated "Each time you fetch, *all* new commits in the repository are
added to your local repository". I agree that it updates my local
repositiory but my coworker said I needed to fetch to update the version of
releaseV4.x under remotes before I checked it out into a new branch on my
local. I was assuming that being under remotes meant it was not local but
at origin and fetch would only update my local copies.
Your assumption is a bit off. A branch being under remotes doesn't mean that it is not local. Rather, it means it doesn't belong to your local repository - you cannot commit directly to it. If you check it out, you create a new local branch that is configured to "track" origin's branch, and those two branches are kept in sync locally by merging (possibly fast-forward) or rebasing. Hope that helps.
Yes, it does: - Make sure you have "all branches" and "show remote branches" is on in the main view. - Find the commit with the right flag (e.g. origin/master), right-click, merge. (There is no context-menu item if you right-click the branch name in the origin branch list, though.)
Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going. The ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event