In some other cases, like the user calling ' git reset -merge' ( man) or ' git merge -quit' ( man), the autostash is not applied, but saved in the stash list. Since ' git merge' ( man) learned ' -autostash' in a03b555 (" merge: teach -autostash option",, Git v2.27.0-rc0 - merge listed in batch #5), ' cmd_merge', once it is determined that we have to create a merge commit, calls ' create_autostash' if ' -autostash' is given.Īs explained in a03b555, and made more abvious by the tests added in that commit, the autostash is then applied if the merge succeeds, either directly or by committing (after conflict resolution or if ' -no-commit' was given), or if the merge is aborted with ' git merge -abort' ( man). However, if ' checkout_fast_forward' fails, the autostash is not applied to the working tree, nor saved in the stash list, since the code simply calls 'goto done'.īe more helpful to the user by applying the autostash in that case.Īn easy way to test a failing fast-forward is when we are merging a branch that has a tracked file that conflicts with an untracked file in the working tree.Īnd: merge: apply autostash if merge strategy fails Since ' git merge' ( man) learned '-autostash' in a03b555 (" merge: teach -autostash option",, Git v2.27.0-rc0 - merge listed in batch #5), ' cmd_merge', in the fast-forward case, calls ' create_autostash' before calling ' checkout_fast_forward' if '-autostash' is given. This is now more rebust: merge: apply autostash if fast-forward fails This means that you can run the operation on a dirty worktree. Merge-options now includes in its man page: -autostash:: -no-autostash::Īutomatically create a temporary stash entry before the operationīegins, record it in the special ref MERGE_AUTOSTASH Mention it in the description of the '-autostash' option for ' git merge' ( man). The documentation for ' git merge -abort' ( man) and ' git merge -quit' ( man) both mention the special ref ' MERGE_AUTOSTASH', but this ref is not formally defined anywhere. (Merged by Junio C Hamano - gitster - in commit 5fef3b1, ) Documentation: define ' MERGE_AUTOSTASH' See commit e082631, commit 12510bd, commit fd441eb, commit 9938f30 () by Philippe Blain ( phil-blain). The local changes stashed by " git merge -autostash" ( man) were lost when the merge failed in certain ways, which has been corrected with Git 2.33 (Q3 2021). So in your case: git config -global tostash true Teach pull to pass -autostash to merge, just like it did for rebase. However, in the last patch, merge learned -autostash as well so there's no reason why we should have this restriction anymore. In all other situations where the merge state is removed using remove_merge_branch_state() such as aborting a merge via git reset -hard, the autostash is saved into the stash reflog instead keeping the worktree clean.īefore, -autostash only worked with git pull -rebase. A merge is aborted using git merge -abort.An incomplete merge is commit using git commit.When an autostash is generated, it is automatically reapplied to the worktree only in three explicit situations: Previously, they had to run something like git fetch. This option is useful when a developer has some local changes on a topic branch but they realize that their work depends on another branch. Implement the -autostash option and corresponding toStash option in merge which stashes before merging and then pops after. This option is missing in merge, however. In rebase, one can pass the -autostash option to cause the worktree to be automatically stashed before continuing with the rebase. (Merged by Junio C Hamano - gitster - in commit bf10200, ) merge: teach -autostash option See commit d9f15d3, commit f8a1785, commit a03b555, commit 804fe31, commit 12b6e13, commit 0dd562e, commit 0816f1d, commit 9bb3dea, commit 4d4bc15, commit b309a97, commit f213f06, commit 86ed00a, commit facca7f, commit be1bb60, commit efcf6cf, commit c20de8b, commit bfa50c2, commit 3442c3d, commit 5b2f6d9 (), commit 65c425a (), and commit fd6852c, commit 805d9ea () by Denton Liu ( Denton-L). You won't see that message anymore with Git 2.27 (Q2 2020), because " git merge" learned the " -autostash" option and the toStash new setting. Please commit your changes or stash them before you merge
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |