2

Like an idiot, I made changes out of scope of my current branch.

I changed 5 files

 M app/form_models/car_registration/basics.rb M app/form_models/car_registration/horse.rb M app/views/car_registration/basics.rb M app/views/car_registration/horse.html.erb M spec/factories/car.rb M spec/form_models/car_registration/basic_spec.rb 

I would like to commit my basics.rb files to my branch, basics, and my horse.rb files to a new branch, horse. I already did git checkout -b horse, and all the files displayed. I have not committed yet. What do I do?

1 Answer 1

3

you should add the files you want to commit

git add basics.rb

and then commit

git commit -m "your message"

then stash changes

git stash

change branch

git checkout -b new_branch

Unstash changes

git stash pop

and commit all changes in your new branch

git commit -am "commit message".

Cheers

Sign up to request clarification or add additional context in comments.

3 Comments

I think it worked, but I also changed the name of the branch at the end and now getting fatal: feat/mvc/car-registration/horse cannot be resolved to branch. when I do git push --set-upstream origin feat/mvc/car_registration/horse
Good answer, but the stash steps aren't necessary here. After the first commit, create the new branch as you did, then just add and commit again.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.