문제

I was working on my Rails project which is checked into Git. I read tutorials and they said for every time you start to change something, check out a branch.

However, accidentally I made some changes but did not check out a branch.

What should I do now?

What commands can I run so that Git takes my new changes and push them on my repository?

도움이 되었습니까?

해결책

git stash
git checkout $correct_branch
git stash apply

Of course, if your changes are already on the branch you're going to put them on, just commit and go with it.

I hope you added a commit into jkp's answer. I can see somebody running that exact sequence without doing a commit and thus wiping out all their uncommitted changes...

다른 팁

It's not mandatory to make a branch, just best practice. It's perfectly legimate to work against master if you want. If you didn't create an explicit branch then you'll be working against master anyway and can push to that.

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