How to specify current branch after re-initializing the repository in Git?

StackOverflow https://stackoverflow.com/questions/22214352

  •  10-06-2023
  •  | 
  •  

문제

I have accidentally deleted my .git directory

I've reinstantiated the repository with git init and readded my remote with git remote add origin git@foo.bar.bazz

How do I specify which branch I am currently on without losing my work?

도움이 되었습니까?

해결책

I ended up doing the following sequence:

git add .gitignore

git commit -m "temp

git stash

git checkout initial_branch_i_was_on

git fetch

git rebase origin/develop

git stash pop

And then manually resolving the handful or rebase issues. Everything said and done it was painless enough. Whether or not there is a better way I don't know.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top