Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Branches and remotes

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?




2 answers

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.

Thanks again. 

I ain't the sharpest knife in the drawer but maybe my assumptions would be better if there was a user's manual.

You haven't actually specified which you use, but for Git you might check out the Git book:

One addition: if you just need to merge an origin/ branch into your own, you don't need to check it out first. You can merge the origin branch into your branch. (After a fetch to make sure the origin branch reference is up-to-date.)

I tried that with SourceTree, and its UI doesn't give you the option.

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.)

Hmm, good point. I definitely only tried the branch list.

yes I am also looking for this type of more suggestions bcz my blogs progress is going slow day by day and need some guidance about to solve this issue.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

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 ...

3,713 views 19 19
Join discussion

Community Events

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

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you