Pergunta

I have been working on a branch (BR1) and have made a few changes that I don't want to commit. For example, some local configuration. I have been told that branch BR1 has been renamed to BR2.

Now, this is what I did: Save the local changes

$ git stash

Update branch information in my local

$ git fetch

point to BR2

$ git checkout BR2

(at this point, I have a detached head)

apply back my stash

$ git stash apply

What did I do wrong? or What do I need to do so that my working branch gets changed from BR1 to BR2 and still retain my local uncommitted changes?

$ git branch -a
*(detached from BR2)
master
BR1
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/BR2
remotes/origin/BR1
Foi útil?

Solução

If BR1 was renamed as BR2, that means the git fetch have brought "origin/BR2".

To be sure, I would:

  • create a new local branch referring that new name:

    git checkout --track -b BR2 origin/BR2
    
  • keep BR1 around (and then delete it if BR2 looks good)

  • apply the stash on BR2.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top