HelloWorld
HelloWorld

Reputation: 3739

Can I branch before committing to git?

I accidentally forgot to branch before making changes to code. I have not committed anything.

If I branch, will the code follow me to the new branch?

Upvotes: 1

Views: 57

Answers (2)

ChatterOne
ChatterOne

Reputation: 3541

If you want to be 100% clean, I'd say the proper way is to go for

  • git stash
  • git branch new_branch
  • git stash pop

(Although I prefer git push master:new_branch to create a new branch, and then track it with git checkout -t origin/new_branch)

Upvotes: 1

Victor
Victor

Reputation: 127

Yes, if you have not committed your changes yet. You can create a new branch and all changes made will be passed to that branch.

Upvotes: 4

Related Questions