git-stash

Git stash: “Cannot apply to a dirty working tree, please stage your changes”

 ̄綄美尐妖づ 提交于 2019-11-27 19:41:01
问题 I am trying to apply changes I stashed earlier with git stash pop and get the message: Cannot apply to a dirty working tree, please stage your changes Any suggestion on how to deal with that? 回答1: When I have to apply stashed changes to a dirty working copy, e.g. pop more than one changeset from the stash, I use the following: $ git stash show -p | git apply -3 && git stash drop Basically it creates a patch pipes that to the apply command if there are any conflicts they will need to be

What's the difference between git stash save and git stash push?

一笑奈何 提交于 2019-11-27 18:57:28
When should I use git stash save instead of git stash push and vice-versa? git stash save accepts a single non-option argument — the stash message. git stash push accepts the message with option -m and accepts a list of files to stash as arguments. VonC Just to be clear, starting Git 2.15/2.16 (Q1 2018), git stash save has been deprecated in favour of git stash push (though git stash save is still available for the time being). See commit c0c0c82 , commit fd2ebf1 , commit db37745 (22 Oct 2017) by Thomas Gummerer ( tgummerer ) . (Merged by Junio C Hamano -- gitster -- in commit 40f1293 , 06 Nov

In git, is there a way to show untracked stashed files without applying the stash?

时光毁灭记忆、已成空白 提交于 2019-11-27 17:07:39
If I run git stash -u , I can stash untracked files. However, said untracked files don't show up at all with git stash show stash@{0} . Is there any way to show untracked stashed files without applying the stash? Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from The commit which introduced the -u feature, 787513... , and the way the rest of the documentation for git-stash phrases things... or just by doing git log --graph stash@{0} ) You can view just the "untracked" portion of the stash via: git show stash@{0}^3 or,

How can I rename a git stash?

狂风中的少年 提交于 2019-11-27 16:50:51
I have a stash with an incorrect name. I would like to fix the name so it's accurate. How can I rename a stash? Let's assume your stash list looks like this: $ git stash list stash@{0}: WIP on master: Add some very important feature stash@{1}: WIP on master: Fix some silly bug First, you must remove stash entry which you want to rename: $ git stash drop stash@{1} Dropped stash@{1} (af8fdeee49a03d1b4609f294635e7f0d622e03db) Now just add it again with new message using sha of commit returned after dropping: $ git stash store -m "Very descriptive message" af8fdeee49a03d1b4609f294635e7f0d622e03db

How to unstash only certain files?

别说谁变了你拦得住时间么 提交于 2019-11-27 16:34:38
I stashed my changes. Now I want to unstash only some files from the stash. How can I do this? As mentioned below , and detailed in " How would I extract a single file (or changes to a file) from a git stash? ", you can apply use git checkout or git show to restore a specific file. git checkout stash@{0} -- <filename> That does overwrite filename : make sure you didn't have local modifications, or you might want to merge the stashed file instead . (As commented by Jaime M. , for certain shell like tcsh where you need to escape the special characters, the syntax would be: git checkout 'stash@{0

Difference between git stash pop and git stash apply

柔情痞子 提交于 2019-11-27 16:33:38
I've been using git stash pop for quite some time. I recently found out about the git stash apply command. When I tried it out, it seemed to work the same as git stash pop . What is the difference between git stash pop and git stash apply ? John Zwinck git stash pop throws away the (topmost, by default) stash after applying it, whereas git stash apply leaves it in the stash list for possible later reuse (or you can then git stash drop it). This happens unless there are conflicts after git stash pop , in which case it will not remove the stash, leaving it to behave exactly like git stash apply

Stash changes to specific files

左心房为你撑大大i 提交于 2019-11-27 11:46:49
I have a large git project that I, stupidly, imported to eclipse and ran an autoformat on. Now, every file in the project is showing as modified. Rather than commit my formatted files, I would rather revert all the files that I have only been formatted and not had other changes. For instance: $ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # (commit or discard the untracked or modified content in submodules) # modified: dir/file1.cpp #

Resolving Git merge conflicts

若如初见. 提交于 2019-11-27 11:20:44
问题 A Git repository has been cloned on several developers' local machines. Some changes have been made to the code in the repository. We're now getting the error: error: Your local changes to the following files would be overwritten by merge: public_html/sites/file public_html/sites/file1.txt public_html/sites/file2.txt Please, commit your changes or stash them before you can merge. Aborting I've read quite a few threads online, and several different options have been suggested. One approach was

Is git stash branch-specific or for the whole repository?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 10:04:30
问题 I went into a branch and did some work. I wanted to go into another branch but didn't want to commit so I did git stash . Then I did git checkout <otherbranch> . I did some work there and, just like in the first branch, I wanted to switch out of it before committing the work. So I did git stash there too. I switched back to the first branch and tried to unstash it ( git stash pop ) thinking it would get the stash from that specific branch. I was surprised that it unstashed the stash from

Git stash pop- needs merge, unable to refresh index

十年热恋 提交于 2019-11-27 10:03:36
问题 I can't pop my stash because I merged a branch which apparently conflicts with my stash and now my stash is seemingly unable to be popped. app.coffee: needs merge unable to refresh index Anyone know how to resolve this? FIXED! Turns out the actual issue was an unresolved merge conflict from the merge, NOT that the stash would cause a merge conflict. Resolution: Commit the conflicted file. 回答1: First, check git status . As the OP mentions, The actual issue was an unresolved merge conflict from