![]() So now there is no error now can apply stash git stash apply can do this process for any number of stash files. So it was giving error that "both modified" So now to solve this issue check the status of your files git status So it shows the list of stashes in my case there were 2 stashes the name of the stashes are displaying like this have need changes from so when i try to get it by this command git stash apply was getting error needs merge To solve this issue first i have to check the stash list by git stash list Then in profile branch i have also done some changes and then want to come back again to the develop so i have to stash the changes again by git stashīut when i come to develop branch and tried to git the stash changes by git stash apply I was facing the same issue because i have done some changes in my develop branch and then want to go to the profile branch. Note: While git restore command is experimental yet, it should be stable enough to be used (thanks to a comment by refer to it for more details on that). Note: Forgetting to write -staged option could spawn a super-hungry dragon to eat your past two days, in the case of not using a good text-editor or IDE. you don't want to commit it now): git restore -staged path/to/file.txt So, to stage it (and maybe commit it): git add path/to/file.txtĪnd to make it unstaged (e.g. This means, unmerged paths are those you should either move into staged or unstaged areas, as Git can work only with these two.Įven in recent versions of Git, when you do a git status, it tells you the how (woah! You should ask yourself how you haven't seen this yet): $ git status If you have noticed, this section is between two staged and unstaged sections. If there are some unresolved merge conflicts to Git, it is shown in a separated Unmerged paths section, with the files marked as both modified (always?). ![]() Generally, git status can tell you what Git knows now. ![]() Note that, the merge is not necessarily caused by a git merge, but also by a git stash pop, for example. In this case, you should inform Git: "Hey, there are no conflicts from the previous merge!". Although you may already edited those files and resolved the conflicts, but Git is not aware of. The problem is, one or more files had conflicts previously, and Git still sees them as unresolved. The reason has already been pointed out by the accepted answer, but it's somehow incomplete (and also the solution). Well, initially, we should know the root of the error, then the solution will become easy. aborting the current merge completely, allowing the git stash pop to be applied. HEAD is now at ff2e1e2 Add more steps for optional information for scanning. What the blog post's author did was: git reset -hard origin/mallard-documentation See " How do I fix merge conflicts in Git?" What you did was to fix the merge conflict (editing the right file, and committing it): You can find a similar situation 4 days ago at the time of writing this answer (March 13th, 2012) with this post: " ‘Pull is not possible because you have unmerged files’": git stash pop You can then git stash the rest if you want. If you do not want to commit, just git add yourFile is enough. Solution: in this case, simply add and commit your local file.Īctually, just git add - yourFile, or (if you don't want those changes) git reset - yourFile (to unstage it) is enough to get past the error message. That is where git status would mention that file as being " both modified" Stack Exchange Network Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build. which is probably what you're looking for.The actual issue was an unresolved merge conflict from the merge, NOT that the stash would cause a merge conflict. Then I needed to quickly produce a fix for something so I stashed my changes (git stash) edited file (vi file) committed (git commit). # git says: "CONFLICT (content): Merge conflict in test.txt" # add "test3" changes to the index, then re-try the stash: # git complains "Cannot apply to a dirty working tree, please stage your changes" Git add test.txt & git commit -m "Initial version" To be clear, this is the process I'm talking about: mkdir test-repo & cd test-repo & git init If not, resolve them as usual with git mergetool, or manually with an editor. If there are no conflicts, you're golden. The stash command takes the uncommitted changes in your working directory, both the updated tracked files and staged changes, and saves them. ), then git stash apply (and, presumably, git stash pop) will actually do a proper merge. What should you do Git Stash Luckily, Git provides a mechanism to handle cases like this through the command git stash. I just discovered that if your uncommitted changes are added to the index (i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |