https://stackoverflow.com/questions/1394797/move-existing-uncommitted-work-to-a-new-branch-in-git
Update 2020 / Git 2.23
Git 2.23 adds the new switch
subcommand in an attempt to clear some of the confusion that comes from the overloaded usage of checkout
(switching branches, restoring files, detaching HEAD, etc.)
Starting with this version of Git, replace the checkout command with:
git switch -c <new-branch>
The behavior is identical and remains unchanged.
Before Update 2020 / Git 2.23
Use the following:
git checkout -b <new-branch>
This will leave your current branch as it is, create and checkout a new branch and keep all your changes. You can then stage changes in files to commit with:
git add <files>
and commit to your new branch with:
git commit -m "<Brief description of this commit>"
The changes in the working directory and changes staged in index do not belong to any branch yet. This changes the branch where those modifications would end in.
You don't reset your original branch, it stays as it is. The last commit on <old-branch>
will still be the same. Therefore you checkout -b
and then commit.
Không có nhận xét nào:
Đăng nhận xét