Oops. Very simple. Make a new branch from where you are.
I'm working on the master branch. I create file1 and commit. Date >file1 git add file1 git commit -m 'added file1' I create file2 and commit.
Date >file2 git add file2 git commit -m 'added file2' Whoops. I may want to use file2, someday, but it's definitely not something that should be put in the master branch. Oops.
Very simple. Make a new branch from where you are: git checkout -b savingfile2 This will make the file2 change the commit for savingfile2. Now go back and unwind one step on master git checkout master git reset --hard HEAD~1 At this point, the commits leading up to master will reflect the addition of file1, and the additional commit between master and savingfile2 will be the addition of file2 to that.
If you make more changes to master, and then want to bring file2 back eventually, you'll want to rebase that side-branch onto the new master: date >file3 git add file3 git commit -m 'adding file3' date >file4 git add file4 git commit -m 'adding file4' And now we finally want file2: git checkout savingfile2 git rebase master # might need to fix conflicts here git checkout master git merge savingfile2 # will be a fast-forward git branch -d savingfile2 # no need any more That should do it.
What you should do is what you should have done when you noticed your mistake of commiting file2: undo the commit (instead of creating a new branch): git checkout master git reset HEAD^ This leaves file2 untracked and unharmed and possible modifications uncommited. Then you should (have) stash(ed) the uncommited modifications in case you want to use them later: git stash save "modifications that should not be in the master branch" Stashing gets rid of any local changes, which allows master to be made point to new-branch: git merge new-branch The goal here was to eliminate the divergence between the two branches, i.e. Make master an ancestor of new-branch.
This way no actual merging would have to occur, and the last command would just fast-forward the master branch (provided there are no local changes).
– kubi Jan 8 '10 at 5:03 You can use (interactive) rebase to drop arbitrary commits from along the commit history (as opposed to git reset) as long as those commits haven't been pushed anywhere. – Tomi Kyöstilä Jan 8 '10 at 14:05.
(provided everything is committed) master and new-branch are just some pointers to some SHA1: $ git checkout master #start from master $ git branch tmp # tmp points on master HEAD $ git checkout new-branch # switch to new-branch $ git branch -f master new_branch # master points at new-branch HEAD $ git checkout tmp # switch back to *former* master branch $ git branch -f new_branch tmp # new-branch points at former master HEAD $ git checkout master # go to new master $ git branch -D tmp # remove tmp pointer ... and you're done. (disclaimer: not tested yet, so try it with caution ;) ) See: a similar approach in the paragraph "Fixing mistakes without git-reset" of "Branching and merging with git", and also in this thread.
This looks like just what I need. Thanks! – kubi Jan 8 '10 at 12:59.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.