0

I've somehow got myself into a git mess. (Hosted in visualstudio.com).

I have a basic repo with just 'master'. I want to now have a gitflow scenario working. So, I want to create 'develop' And then branch off develop for features.

To check my local branches now, I execute git branch -r

origin/HEAD -> origin/master
origin/develop
origin/master

This looks strange to me. It seems on the server, I have 3 branches. But not sure if it's right, as far as gitflow goes. Not sure what the HEAD one is doing.But maybe it's just saying that master is HEAD?

I run git branch -l

* develop
  master

That seems to indicate that locally, on my PC, I have two branches, and I am in develop. Again, seems OK to me. Not sure if it's 'tracked' though to the server.

Now, I want to do a feature called test.

So in source tree, as my command lines skills are junk, I try this:

enter image description here

But am faced with a shocker of an error:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks branch develop/test fatal: cannot lock ref 'refs/heads/develop/test': 'refs/heads/develop' exists; cannot create 'refs/heads/develop/test' Completed with errors, see above.

I go to visualstudio.com to check what it thinks is happening, and my branches look like this:

enter image description here

I am hopefully making a silly error, but how can I get a good flow of:

master, develop, and then develop/feature_name going... with pull requests into master?

Edit: I think I've had a brain fart! I don't create a develop/my_branch branch! I think I create a feature/my_branch OFF develop. And then I have this:

enter image description here

And then I marge my feature branch into develop, and then can do a pull request from develop into master once develop goes live. Does this seem right?

Craig
  • 18,074
  • 38
  • 147
  • 248
  • https://stackoverflow.com/search?q=%5Bgit%5D+cannot+lock+ref+exists – phd Mar 03 '20 at 01:01
  • You cannot have refs 'refs/heads/develop/test' and 'refs/heads/develop' at the same time. – phd Mar 03 '20 at 01:02
  • Thanks phd. I'm not sure how/who created anything wih refs in it. Should I be deleting all branches (except master, which has all my code and history), and start again by just creating a new 'develop' branch, based on master, from which I can then branch? – Craig Mar 03 '20 at 01:03
  • No need to delete everything. Just decide what branches you do want. If you want `develop` you cannot have it at the same time with `develop/test` but you can have `develop` and `develop-test`, e.g. – phd Mar 03 '20 at 01:06
  • AH, OK. I may have confused myself. And what you say may make sense. I am hoping to have a master branch, and lock it for any changes. I'd then like a develop branch, which has the latest code currently not in prod, but in development. When I want to work on a feature, I thought I create a branch develop/my_feature. Work on that... push to the server now and again. When done, pull request from develop/my_feature into develop. And then at some point, marge develop into master when done. In source tree, I thought I'd then see branchs under the develop branch, with all the 'sub' branches. – Craig Mar 03 '20 at 01:10
  • phd - I made an edit at the bottom. I think it's more my understanding that was aat fault, as opposed to an error. – Craig Mar 03 '20 at 01:17

0 Answers0