git: undo a git add keeping previous staged version? (does the index have history?)
Hmm, OK, I have a question that's similar to Undo git add before commit, but with an important difference:
I'm running some code that's generating files which I'll add to my repository when complete. The code that's generating the files is new code, and in flux, so I'm sometimes running it more than once, with changes.
Along the way, I'm adding the generated files to the index, so they'll be ready for one big commit at the end. This also allows me to check to see if my changes to the code create changes in the output, and if so, what those changes are. But... I accidentally ran another git add on a file that had showed up both in the
Changes to be committed section (as a
new file) and the
Changes not staged for commit section (as
modified). I meant to run a git diff on it, but I slipped and re-added it, so now I don't have a way to diff it (that I know of), so...
Is there a way to undo just the last staging operation, such that a previously-added version will still/again be in the index, and the modified file will again be in my working tree, so that I can diff it?
None of this is committed or anything, as the goal is to commit it all together when I'm done with this little round of development. I just really like that git can normally show me changes to new files, before they're committed... but... I missed a chance at that, and am now wondering if there's a way to get it back. ?
The things I've looked up so far seem to be able to get me back to the last commit (no file) or the current state of the file (which I have anyway), but not the in-between of going to a previous version from the index, that's never been part of a commit. Any hints on even whether or not this is possible (even a solid answer that it's not, preferably with an explanation of why this is the case) would be appreciated.
I am modifying someone else's (non-git) code. I downloaded the original, ensued my modifications, and jumped the gun and made the modified version my first commit. This was a mistake, I should have ad
Git branch heads and tags are pointers to commits, and these pointers can move either implicitly (after a commit) or explicitly (after a branch -m). Does Git record the history of the state of these p
I have a fuzzy idea of what the git index contains as one does git-adds and git-commits, but I don't have a clue of what happens to these contents when one does a git-merge. I'm particularly intereste
Background: I'm in the process of cleaning up a project before releasing it as open-source. During the code history there's been a bunch of things I don't really want to show up in a public repository
I'm new to git an basically following the directions from here http://genaud.net/2008/08/clearcase-globally-git-locally/ to try and mirror a clearcase snapshot. I create the git repository on the snap
I have four times commit to my git. See log f1f55a9 5 hours ago user UI improvement master 17114a0 2013-04-16 user enhancement d72934e 2012-12-24 user enhancement bf81a9e 2012-11-27 user origin I wo
I did: git reset --soft ^HEAD when I guess I really meant: git reset --soft HEAD Now all of my day's work is gone. Is it possible to move back up the ladder to capture what I did today The reason
I've been a CVS user in the past, and though I consider Git a good version control system, I am missing a feature I had in CVS. Specifically, I want to see a file's version history, such as the tags o
[wen@localhost git-master]$ /usr/local/bin/git --version git version 1.9.0.GIT [wen@localhost git-master]$ which git /usr/local/bin/git [wen@localhost git-master]$ git --version git version 1.7.1 Ins
I know I can git-show the previous version of a file, but I've got images in my repository! When I git show <revision>:<path-to-image>, it unhelpfully opens them in a pager... It seems git
I am sitting on a cross development chair and created a JFFS2 file system to be used on the target. Inside that tree are several directories and files that have root permissions only. When I git add t
I made a mistake and copied files from a git repository to a new one. The files were changed and I noticed too late that I lost the original file history. Consider the example script below. It creates
Possible Duplicate: View the change history of a file using Git versioning Sometimes I want to step through the history of a particular file. In the past I used P4V and this was very quick and intui
I often have a situation where I have git added a set of files for a commit, but then have to make a modification to those files so end up with the modifications on those same files in Changed but not
I am using Git for Windows (ver. 1.7.8-preview20111206) and even though I have a .bash_history file in my HOME folder, it never automatically gets updated. When I start Git Bash, I can see in the hist
How could I modify git status output to treat each path as a variable which I can use to perform other commands on? Example: $ git status # On branch master # # Changes not staged for commit: # (use
There was an existing bitbucket repo A with over 200 commits. I downloaded the code (without .git files). Created new repo B with all the existing code added in first commit. Then 150 more commits on
I edited a file and did: git add file.py git commit -m 'fixed bug' I then edited another file and performed a minor bug fix. I don't want two commits, one after the other, showing 'bug fix'. I want o
I'm trying to use git add --interactive to selectively add some changes to my index, but I continually receive the Your edited hunk does not apply. Edit again... message. I get this message even if
I am new to git. I have checkout files from remote. I had to delete few files from the git repo. Instead of doing git rm command, I issued unix rm -rf folder command. I need to revert the delete comma
I frequently do a git pull on a live server. If my website fails after a git pull, what is the command to go back to previous version of website which is stable? Thanks
I have a repository which was created by copying files (not the history) from an SVN repository, with many changes added on top since. I have since converted the history in SVN into git, and merged it
git newbie here, bear with me if this is trivial. I cannot find this in some git basic docs seen so far. I did a git add file1 which puts the file into the index. Immediately after this the git dif
So we have a ton of less files that we compile into a 1 line css. When trying to merge this compiled file it keeps failing. I know we can fix the conflict manually with git gui or gitmergetool. But i
I have a question regarding renaming a branch in git. I created a local branch dev and pushed branch to remote. I did lots of work on the dev branch and am updating remote branch regularly. Now I wan
I have two scenario I have a local Git repo, which I moved files into different folder and then committed. The history got lost, how can I get the file history into the moved files. I have a local G
I merged two branches that shouldn't have been merged: A & B. I want to undo that merge, and I can easily do that, returning to the last unmerged state of branch A. However, I want to merge indivi
My project has a file foo that I've been using and checking in with git. I just did some refactoring so that I no longer need the file at all. If I do git rm foo, will the file still exist in older co
I've taken a look at these previous questions already: Howto add a changed file to an older (not last) commit in Git How do I edit a previous git commit? They don't exactly address a particular issu
I downloaded the latest version of git - 126.96.36.199 - from git-scm.com/download/mac After I installed it, if I enter git --version in a terminal window, the version is reported as 188.8.131.52. I ran the unin
I made something very stupid. I made a commit using git commit (file edits + new files) (C). Then I made amend last commit. Then I deleted all files recursively (!) using git rm -r Then I made another
I am writing a tool that has to keep history of (generated) files in a Git repository. One of the requests is that I must be able to take whatever was generated in a specific commit and replay those i
I'm newbie in git and I'm trying to use it as follows (AFAIK it's a quite common workflow for a single developer): Create a feature branch and do some work on it, with some WIP commits. When done, re
Is there anyway to undo a git svn rebase? I incorrectly did some merges and want to just go back to the way things were before I tried to rebase from the central repository.
The reason I am asking this is that I had accidentally done a git commit -a that included a file I did not yet want to commit. My solution was to do the following: git reset --soft HEAD^ git reset --
I need to export a git repository content and import it in a target repository. I know of two alternatives to do it, but they do not solve my problem a) Add the source repository as a remote and do a
I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder? I've previously been doing just a git
By mistake I run the command git add -A and then (when I figured out) I stopped it using Ctrl+C Is there a way to reset the repository to the point before the git add -A? git status shows: # On br
This question already has an answer here: Squash all Git commits into a single commit 8 answers I want to do an explicitly bad thing. I have a project where I am the only developer and I want t
I would like to define a __version__ variable in my module which should be automatically updated on git commit similarly to what SVN keywords do. Is there a way to achieve it in Git? Does anyone have
Possible Duplicate: Undo “git add”? I made the mistake of running: git add . Which added important things such as .bashrc. Even though I run: git rm . When I run: git push project master Everythi
I'm trying to re-write a repo's history using: git filter-branch -f --env-filter ' an=$GIT_AUTHOR_NAME am=$GIT_AUTHOR_EMAIL cn=$GIT_COMMITTER_NAME cm=$GIT_COMMITTER_EMAIL if [[ $GIT_COMMITTER
I tried to add all files, but am not able to add files. What do I need to do? ➜ dotfiles git:(master) git add . ➜ dotfiles git:(master) git status # On branch master # Changes not staged for commit: #
This might be a noob question. Suppose I have a Git repo which already have some files in the staged area by using git add. and then I do a git reset --soft @~ I am happy to see some files I committe
Please help I'm new to Git - Something has gone seriously wrong in my application and I want to restore a previous commit - but nothing is working - No matter what I do I still see the later files on
i have a litte messed up my git repo. I worked on a feature in a separet branch. After finishing the work, i switched to the master to merge it into. But my partner pushed a few files with come in con
I want to see diff on files that I've added to commit (git add something). I can do this: git diff HEAD `git status -s | grep ^M | cut -c 4-` Is there a shorter way?
We have a git project which has quite a big history. Specifically, early in the project there were quite a lot of binary resource files in the project, these have now been removed as they're effective
For a given commit, I need to run blame on the previous version of each line changed but said commit. Having a commit that changes lines 2 and 3 on file a, I want a way to see the output of git blame
I accidentally delete a file from my repo using git filter-branch: git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch images/thumb/a.JPG' HEAD How can I undo this? Is it possible?