Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ability to edit local copies of remote branches

I have difficulty understanding/verifying the following line from Pro Git:

It’s important to note that when you do a fetch that brings down new
remote-tracking branches, you don’t automatically have local, editable
copies of them. In other words, in this case, you don’t have a new
serverfix branch — you have only an origin/serverfix pointer that you
can’t modify.

I tried the following for a repository.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

git clone git://git.bugseng.com/ppl/ppl.git
cd ppl

I removed folder ppl/src/ from my local machine, and made a copy of pre-existing folder ppl/m4/ into ppl/m4 - Copy just so as to locally modify/edit this folder a bit.

Then, I ran git fetch origin just to (I thought) set myself up to be in the situation mentioned in the book’s quote above. I (of course) do not have any write access to this online repository.

Now, I am easily able to do git add . and git commit without any errors. Output of git status is:

:~/ppl$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.

all as expected. That is, I have been able to make a commit and edit the branch locally. I am unable to reconcile this with the quote from the book which states that I would not have local editable copies of them.

>Solution :

Notice that the phrases you quoted refer to a serverfix branch — not to master.

In the case of master (or whatever the remote HEAD is), when you clone you are given a local copy automatically; thus there was no need for you to make one.

But if there had been any other branches, clone does not make local copies of those for you, and a mere fetch would not have given you local copies of them either. You might have remote-tracking branches such as origin/someBranch, but if you wanted to edit someBranch, you’d have to create it first.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading