[Solution] fatal: ambiguous argument ‘stash@‘: unknown revision or path not in the working tree.

From github.com:26huitailang/learn-sth-everyday
   7cf57b0..d9f7ae2  master     -> origin/master
Updating 7cf57b0..d9f7ae2
error: Your local changes to the following files would be overwritten by merge:
    liaoxuefeng/awesome-python-webapp/LICENSE
Please, commit your changes or stash them before you can merge.
Aborting

Cause: at home, the desktop updates the files and synchronizes them to the remote, while another computer modifies the files locally and does not submit them to the library

Solution:
the processing method is very simple, mainly by using git stash command, which is divided into the following steps

git stash

Saving the current work progress will save the status of the temporary storage area and the work area respectively. Git stash list can be used to display the progress list, which also implies that git stash can save the work progress many times and make a choice when restoring

in which stash @ {} marks the information just saved. WIP means work in progress, which means work area
2. Git pull remote to local

After saving the local progress, you can pull. Git pull is equivalent to git fetch and git merge

git pull

You can see that my local information has been covered remotely. Remote file changed is a commit that I submit directly on GitHub. Another sentence that covers my local area

Don’t worry, because we save the local work progress, we can recover the previous information from the stash list

3. Restore the contents of the staging area

git stash pop stash@{
   
   1}
or
git stash apply stash@{
   
   1}

At this point, we encounter another problem, prompt:

fatal: ambiguous argument 'stash@': unknown revision or path not in the working tree.

Because I use the operation on the PowerShell, I find the answer on the so:

Your shell is eating your curly brackets, so while you say stash@{
   
   1}, git sees stash@1 and that makes no sense to it. Quote the argument or reconfigure your shell to only expand curly brackets when there is a comma between them (zsh can be configured either way, bash only expands curly brackets with comma or range between them, other shells may behave one or other way).

In short, for escape {} to be eaten on windows, just add “backtick”

$ git stash apply stash@`{
   
   1`}

The system may prompt the following similar information:
it means that the system automatically merges the modified contents, but there are conflicts, and the conflicts need to be resolved

4. The conflict resolution part of the file
directly open the file with file conflict

The content between updated upstream and = = = = is the content pulled down, and the content between = = = = and staged changes is the content modified locally. In this case, GIT doesn’t know which line of content is needed, so it needs to determine the content itself. Do not submit until you have finished
those who can use mergetool can also use this tool

5. Finally remember to delete the progress list with git stash clear, otherwise the stash list will become very complicated

Similar Posts: