Bug 分支

C:otherslearnGit>git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in C:/others/learnGit/.git/

C:otherslearnGit>notepad 1.txt

C:otherslearnGit>git add 1.txt

C:otherslearnGit>git commit -m "111222"
[master (root-commit) 5950967] 111222
 1 file changed, 2 insertions(+)
 create mode 100644 1.txt

C:otherslearnGit>git switch -c dev
Switched to a new branch 'dev'

C:otherslearnGit>notepad 1.txt

C:otherslearnGit>git stash
Saved working directory and index state WIP on dev: 5950967 111222

C:otherslearnGit>git switch master
Switched to branch 'master'

C:otherslearnGit>git switch -c fixBug
Switched to a new branch 'fixBug'

C:otherslearnGit>notepad 1.txt

C:otherslearnGit>git add 1.txt

C:otherslearnGit>git commit -m "222->333"
[fixBug ab99458] 222->333
 1 file changed, 1 insertion(+), 1 deletion(-)

C:otherslearnGit>git switch master
Switched to branch 'master'

C:otherslearnGit>git merge --no-ff -m "merged bug fix 101" fixBug
Merge made by the 'recursive' strategy.
 1.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

C:otherslearnGit>notepad 1.txt

C:otherslearnGit>
C:otherslearnGit>
C:otherslearnGit>git branch -d fixBug
Deleted branch fixBug (was ab99458).

C:otherslearnGit>git branch
  dev
* master

C:otherslearnGit>git switch dev
Switched to branch 'dev'

C:otherslearnGit>git stash list
stash@{0}: WIP on dev: 5950967 111222

C:otherslearnGit>git reflog
5950967 (HEAD -> dev) HEAD@{0}: checkout: moving from master to dev
775c57c (master) HEAD@{1}: merge fixBug: Merge made by the 'recursive' strategy.
5950967 (HEAD -> dev) HEAD@{2}: checkout: moving from fixBug to master
ab99458 HEAD@{3}: commit: 222->333
5950967 (HEAD -> dev) HEAD@{4}: checkout: moving from master to fixBug
5950967 (HEAD -> dev) HEAD@{5}: checkout: moving from dev to master
5950967 (HEAD -> dev) HEAD@{6}: reset: moving to HEAD
5950967 (HEAD -> dev) HEAD@{7}: checkout: moving from master to dev
5950967 (HEAD -> dev) HEAD@{8}: commit (initial): 111222

C:otherslearnGit>git cherry-pick 775c57c
error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given.
fatal: cherry-pick failed

C:otherslearnGit>git cherry-pick 775c57c
error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given.
fatal: cherry-pick failed

C:otherslearnGit>git cherry-pick 775c57c
error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given.
fatal: cherry-pick failed

C:otherslearnGit>git cherry-pick -m 1 775c57c
[dev 37b410a] merged bug fix 101
 Date: Tue May 18 15:40:37 2021 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)

C:otherslearnGit>git notepad 1.txt
git: 'notepad' is not a git command. See 'git --help'.

C:otherslearnGit>notepad 1.txt

C:otherslearnGit>git stash apply
Auto-merging 1.txt
CONFLICT (content): Merge conflict in 1.txt

C:otherslearnGit>git stash pop
1.txt: needs merge
The stash entry is kept in case you need it again.

C:otherslearnGit>git status
On branch dev
Unmerged paths:
  (use "git restore --staged <file>..." to unstage)
  (use "git add <file>..." to mark resolution)
        both modified:   1.txt

no changes added to commit (use "git add" and/or "git commit -a")

C:otherslearnGit>
error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given.
fatal: cherry-pick failed
中途出现  is a merge but no -m option was given.
可以参考这边https://segmentfault.com/q/1010000010185984?tdsourcetag=s_pctim_aiomsg
git stash 暂时存储起来
git stash list 查看储存的有哪些
git stash apply 恢复
git stash drop 删除
git stash pop 恢复的同时也删除
git stash apply stash@{0} 指定恢复到哪一个
git cherry-pick -m x XXXXX 主干分支上修复的这边也跟着修复



 
原文地址:https://www.cnblogs.com/Galesaur-wcy/p/14781275.html