A
A
Automat2017-08-10 17:42:26
git
Automat, 2017-08-10 17:42:26

Is it possible to switch to a branch and save the changes?

I had to cut a new branch that comes out of the master, but I forgot to switch and started sawing in the old one. When I try to switch to the master, it says that it will lose the changes
git checkout master
Answer:

error: Your local changes to the following files would be overwritten by checkout:
project/folder/file.php
Please commit your changes or stash them before you switch branches.
Aborting

OK. I create a new branch, do git add* these changes get into it git status shows that they are indexed. I think now I'll switch to the master, make a new branch, and add changes from this (temporary) one to it. But when switching to master, the same error is still the same. How to overcome it by saving file changes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wexter, 2017-08-10
@nomotrack

git stash

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question