git bug branch

The current branch work site is now "stored".

$ git stash

stashFunction, you can "store" the current work site, and continue to work after the site is restored.

 

Each bug can be fixed with a new temporary branch, after which the branch is merged and the temporary branch is deleted.

First decide on which branch to fix the bug. Assuming it needs to be fixed on the masterbranch, mastercreate a temporary branch from:

$ git checkout master
$ git checkout -b issue-101

Fix the bug, then submit:

$ git add readme.txt
$ git commit -m "fix bug 101"

After the fix is ​​complete, switch to the masterbranch, complete the merge, and finally delete issue-101the branch:

$ git checkout master
$ git merge --no-ff -m "merged bug fix 101" issue-101
$ git branch -d issue-101

 

Then go back to devthe branch to work:

$ git checkout dev
$ git status
$ git stash list

The work site is still there, and Git has stored the stash content somewhere, but it needs to be restored. There are two ways:

One is to use git stash applyrecovery, but after recovery, the stash content is not deleted, you need git stash dropto delete it;

Another way is to use git stash pop, and delete the stash content while restoring:

Check again git stash list, you can't see any stash content:

$ git stash list

You can stash multiple times. When restoring, use git stash listView first, and then restore the specified stash. Use the command:

$ git stash apply stash@{0}

Summarize:

When fixing bugs, we fix them by creating a new bug branch, then merge, and finally delete;

When the work at hand is not completed, visit the work site first git stash, then fix the bug, and after the fix, go git stash popback to the work site.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324902003&siteId=291194637