Link to a different branch without touching uninstalled files
git stash
really efficient when pushing dirty changes between branches. In your case, you can apply the following steps:
-
git stash --keep-index
, this will only close unset files -
git stash
, this will write the rest, i.e. supplied files - switch to B1
-
git stash pop
, the staged files will be moved to B1 - switch to B2
-
git stash pop
, uninstalled files will be transferred to B2
After that, you can commit changes to each branch individually.
source to share
I'm sure there is a more elegant way, but all I could come up with is this:
- Commit the delivered files for B2
- Set up non-stationary work on B2
- Switch to B1 then cherries select the last commit of B2 to B1
- Go back to B2, reset to last post (--hard way)
- Scene and copy folded work to B2
EDIT
This question has a detailed answer that does more or less what I suggested.
source to share
If the modified staged and unset files don't change by switching to branch B1, you can switch branches without affecting anything, then you can easily transfer your files and switch back to B2.
However, if your modified files are changed between B1 and B2, you cannot switch branches. In this case, you need to commit your changes before deploying branches.
-
git stash --keep-index
to save and save phased files -
git reset HEAD
for non-installation staged files -
git stash
to keep your previous staged files. -
git checkout B1
to go to branch B1 -
git stash pop
to unlock and remove the last stash -
git commit -a
to commit your previously delivered files to B1 -
git checkout B2
to go to branch B2 -
git stash pop
-
git commit -a
commit all other changes to B2
Be careful with these commands! I'm not a git pro! :-)
source to share