Git Moved files move from one branch to another before clicking

Unfortunately, I committed several files in one branch, but I decided to transfer these files to another new branch. I still have not dragged this file into this thread. So please let me know how to transfer these files to my new branch?

Any suggestion would be appreciated.

+4
source share
3 answers

You can unzip your files with git reset --soft HEAD^, and then hide your changes with git stash. Then you can check the correct target branch of your changes with git checkout your-target-branch, after which you can do git stash popto get your hidden changes, and allow you to add / commit / click in the correct branch.

+1

, :

git checkout -b aNewBranch

x--X--y--y (aBranch, newBranch)

reset ( git log, SHA1, origin/aBanch, )

git branch -f aBranch <sha1>

x--X (aBranch)
    \
     --y--y (newBranch)
0

Suppose the current branch is A. Create a new branch from this branch.

git checkout A
git branch B

Now branch B contains the changes you made to branch A. All that remains to be done is to remove the changes from branch A. This can be done as follows:

git reflog

This will give you a list of all the changes the repo went through. Select the HEAD value to which you want to return branch A.

git reset --hard HEAD<i>

This will do what you intend to do.

0
source

Source: https://habr.com/ru/post/1599640/


All Articles