On Wednesday, January 14, 2015 at 5:07:04 PM UTC+1, Lars Hartviksen wrote:
> A developer made a branch called 2015/January/Feature1234.
> It was later decided that coding should be split into subtasks and 
> branches like this:
> 2015/January/Feature1234/master
> 2015/January/Feature1234/Task1
> 2015/January/Feature1234/Task2
> 2015/January/Feature1234/Task3
> so we did this:
> git branch -d 2015/January/Feature1234
> git push origin :2015/January/Feature1234
> and we created the new branches from DEV.
Generally: You cannot have colliding branch names, and you cannot collide 
with branches' "folder" names. Prefixes (like 2015/) are basically like 
folders on the file system. You cannot have a file called foo and a 
directory called foo/ in the same place.

> Now what happened is I couldn't fetch from origin, because of an error 
> message: 2015/January/Feature1234/master could not be created. Probably 
> because there seemed to be a branch called 2015/January/Feature1234.

Not sure if you had this branch checked out and tracked already in your 
local repository. That would require you too manually delete it first.

> So what I did was try deleting the branch called 2015/January/Feature1234 
> from origin in Sourcetree. This gave me a "doesn't exist" error message. 
> But after that it seems sourcetree realized the branch was deleted and I 
> could fetch from origin and everything seemed to be ok.

My guess here is that SourceTree was out of date for a small period in 
which it still displayed the branch.

> What happened here? Any easy / proper way to fix this?(expecting a few 
> mails from other developers who can't fetch from origin)

The problem is that the fetch operation is both trying to delete file and 
create a directory with the same name, and this is going down in the wrong 
order. It's easy to reproduce:

First: Take a repo, create a branch with the old pattern:

cd foo #some git repo
git branch 2015/January/Feature1234

Now, clone the repo
cd ..
git clone foo foo2
cd foo2
git branch -a
* master
  remotes/origin/HEAD -> origin/master

So far, so good. Now delete the old branch and create the new one in the 
original repo (foo):

git branch -d 2015/January/Feature1234
Deleted branch 2015/January/Feature1234 (was 8deac45).
git branch 2015/January/Feature1234/master 

And then fetch in foo2:
git fetch
error: 'refs/remotes/origin/2015/January/Feature1234' exists; cannot create 
error: Cannot lock the ref 
>From /Users/tfnico/temp/foo
 ! [new branch]      2015/January/Feature1234/master -> 
origin/2015/January/Feature1234/master  (unable to update local ref)
error: some local refs could not be updated; try running
 'git remote prune origin' to remove any old, conflicting branches

So, things are messed up. I try running a prune, as Git advises in the last 
line above:

git remote prune origin
Pruning origin
URL: /Users/tfnico/temp/foo
 * [pruned] origin/2015/January/Feature1234

Now try fetching again. It should work:

[master][~/temp/foo2]$ git fetch
>From /Users/tfnico/temp/foo
 * [new branch]      2015/January/Feature1234/master -> 

Long story short, you broke the rules of Git, and SourceTree did not show 
you the correct error message, nor did it show the solution. 

Morale of the story is, when running into Git problems, try to recreate it 
in a simple repository using the command line tools.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to