views:

43

answers:

2

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

However, accidently 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.

A: 

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.

John Topley
+2  A: 
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...

Autocracy