Bug 分支
C:\others\learnGit>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:\others\learnGit>notepad 1.txt C:\others\learnGit>git add 1.txt C:\others\learnGit>git commit -m "111222" [master (root-commit) 5950967] 111222 1 file changed, 2 insertions(+) create mode 100644 1.txt C:\others\learnGit>git switch -c dev Switched to a new branch 'dev' C:\others\learnGit>notepad 1.txt C:\others\learnGit>git stash Saved working directory and index state WIP on dev: 5950967 111222 C:\others\learnGit>git switch master Switched to branch 'master' C:\others\learnGit>git switch -c fixBug Switched to a new branch 'fixBug' C:\others\learnGit>notepad 1.txt C:\others\learnGit>git add 1.txt C:\others\learnGit>git commit -m "222->333" [fixBug ab99458] 222->333 1 file changed, 1 insertion(+), 1 deletion(-) C:\others\learnGit>git switch master Switched to branch 'master' C:\others\learnGit>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:\others\learnGit>notepad 1.txt C:\others\learnGit> C:\others\learnGit> C:\others\learnGit>git branch -d fixBug Deleted branch fixBug (was ab99458). C:\others\learnGit>git branch dev * master C:\others\learnGit>git switch dev Switched to branch 'dev' C:\others\learnGit>git stash list stash@{0}: WIP on dev: 5950967 111222 C:\others\learnGit>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:\others\learnGit>git cherry-pick 775c57c error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given. fatal: cherry-pick failed C:\others\learnGit>git cherry-pick 775c57c error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given. fatal: cherry-pick failed C:\others\learnGit>git cherry-pick 775c57c error: commit 775c57c573b53afa25a76a2c58fca338c1f60059 is a merge but no -m option was given. fatal: cherry-pick failed C:\others\learnGit>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:\others\learnGit>git notepad 1.txt git: 'notepad' is not a git command. See 'git --help'. C:\others\learnGit>notepad 1.txt C:\others\learnGit>git stash apply Auto-merging 1.txt CONFLICT (content): Merge conflict in 1.txt C:\others\learnGit>git stash pop 1.txt: needs merge The stash entry is kept in case you need it again. C:\others\learnGit>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:\others\learnGit>
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 主干分支上修复的这边也跟着修复