git-stash

Why is a stash represented as 2 commits?

我怕爱的太早我们不能终老 提交于 2019-12-06 17:26:39
问题 When stashing some changes, Git creates two separate commits, 'WIP on branch' and 'index on branch': $ git log --graph --all * commit 98aac13303ca086580c1ec9ccba5fe26c2a8ef3c |\ Merge: 7d99786 82c5c76 | | Author: Tieme <my@email.com> | | Date: Wed Nov 19 09:58:35 2014 +0100 | | | | WIP on development: 7d99786 Last real commit | | | * commit 82c5c763357c401135675a39bfabf9b7f6805815 |/ Author: Tieme <my@email.com> | Date: Wed Nov 19 09:58:35 2014 +0100 | | index on development: 7d99786 Last

Is this a valid visualization of the “git stash” operation?

老子叫甜甜 提交于 2019-12-06 09:09:40
问题 I can not find a good visualization of the git stash operation. So I created my own based on some rare comments on the internet. This this visualization correct? Edit note: I need to change the color of stash@{0} because it's no branch. Where are stashes stored in my .git directory? I think it's a reference and stored in refs , right? Legend: C1, C2 - commits Idx - Index WD - working directory dashed line and dashed borders => free for garbage collection Reworked Image 回答1: The "before git

Move uncommitted changes from current branch to another branch that conflicts with those changes

我怕爱的太早我们不能终老 提交于 2019-12-06 06:06:15
Suppose I am on branch master and I start making some changes. I make the changes to a file which is already opened in Emacs (so under the hood, as checkouts happen, Emacs is unaware unless I revert-buffer constantly). The file did exist in branch other_branch which was intended to be merged into master later on. But the file did not exist in master until I accidentally saved it from Emacs. The changes are uncommitted, but I realize that I shouldn't have been making the changes on master and had intended to checkout a different branch before starting on the changes. I don't want to lose the

Git PathSpec Issue on Git Stash

你离开我真会死。 提交于 2019-12-06 04:08:56
问题 When I run the new version 2.13.0.windows.1 of its new command stash -p -- {pathspec} as git stash -p -- AB.Dir1/Dir2/DestinationHierarchyCreator.cs it reports the error error: pathspec 'AB.Dir1/Dir2/DestinationHierarchyCreator.cs' did not match any file(s) known to git. Yet when I do a git status , where I copied the file from actually , it reports Your branch is up-to-date with 'origin/project/develop'. Changes not staged for commit: (use "git add <file>..." to update what will be committed

Can't discard changes in git

夙愿已清 提交于 2019-12-06 02:29:02
A week or two ago I took some files that I had been archiving with a simple find |sed|tar|xz|gpg bash script, unpacked them all, and put their contents in a git repo, commited, put the next archives content in the repo, committed (rinse and repeat) in order to have a nicer system. All files were edited with on one of my two computers, both using Arch Linux, in either TeXstudio or Vim. I tried to checkout an old version, but its flipping out---it won't let me due to changed that are outstanding. I tried everything I knew how, and then went on Google to find out things I didn't know. There are a

How to recover the index after a git stash / git stash pop?

冷暖自知 提交于 2019-12-05 17:55:44
问题 After adding some changes to the index with git add -p, I then issued a git stash but forgot to add --keep-index. Then I stupidly did a git stash pop, and all my changes to the index were gone. Is there a way to recover the index to the state before the git stash? 回答1: When you've just done git stash pop , the last line in the output is: Dropped refs/stash@{0} (ca82a6dff817ec66f44342007202690a93763949) If you've lost it, see How to recover a dropped stash in Git? to find the commit hash. Once

How to pull into not-the-current-branch?

≡放荡痞女 提交于 2019-12-05 08:27:15
问题 Say my current branch is myfeature. I want to get master up to date. Both git merge git pull always merge into the current branch, as far as I can tell. Is there a way to merge changes from a remote branch (eg, origin/master) into a branch I'm not currently on (master)? I can think of one way: git stash git checkout master git pull origin/master git checkout myfeature git stash apply Is there a better one? (It's possibly my whole question is wrong: would git fetch automatically update master

Strange git case - git stash followed by git stash apply lost uncommitted data?

梦想的初衷 提交于 2019-12-05 07:55:54
I have a file, let's say file.txt I have done git mv file.txt to file1.txt, then I created a new file called file.txt and worked on it. Unfortunately I didn't add that file to git yet. Anyway the problem is that I did git stash, then git stash apply, but the new file.txt disappeared... anyway to get it back? The problem here is mostly a misunderstanding of what git stash save does. It saves only changes to tracked files. Untracked files are not saved by git stash . When you moved file.txt to file1.txt, the new file.txt is an untracked file and will not be saved by git stash . This isn't a bug,

Git stash pop with binary - merge conflict

点点圈 提交于 2019-12-05 04:46:43
I'm trying to do a "git stash pop" with a binary file. It results in a merge conflict. I just want to pull what's in the stash off and overwrite what's in the working directory. What is the easiest way to do that? To restore all files to their stashed version: $ git checkout stash -- . 来源: https://stackoverflow.com/questions/29979038/git-stash-pop-with-binary-merge-conflict

Git alias with two commands (stash pop + merge) executes only the first command. Why? How to execute also the merge?

喜欢而已 提交于 2019-12-05 04:40:25
I set up a git alias like this: git config --global alias.popmerge '!git stash pop && git merge master' Then I call it, like this: git popmerge The " git stash pop " is executed, but the " git merge master " is ignored. If I run " git merge master " right after the " git popmerge "... it sumply runs as expected, performing the merge. I have other aliases with long sequences of commands... and they run flawlessly. It seems something at " git stash pop " makes the alias process to halt ... Is it possible to avoid this behavior? How? Thanks. sehe Have you checked the exit code from stash pop? &&