![]() Saved working directory and index state WIP on master: 0442487 initial The two interesting bits of information here are that we have a modified, but not yet staged, README, and-this is more important for our git stash step-the untracked file X.Īnyway, let's run git stash (which means git stash save) now: $ git stash No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) Had you run git status first, you would have seen this, which might have been a clue, though it's hard to know at first what parts of this deserve what amounts of attention: $ git status We have now reached the stage at which you ran git stash. ![]() We are using other here because we made this, rather than getting it through git fetch.) What stash does, and doesn't do (Note, by the way, that when you run git pull, it effectively runs git merge origin/master, rather than git merge other. Please move or remove them before you merge. So we just go right to the second command, git merge: $ git merge otherĮrror: The following untracked working tree files would be overwritten by merge: ![]() But: we do not (we can not) git fetch your wo-worker's commit in this example, which is why we made a branch named other above in the first place. So, we'll do the two-separate-commands thing. I always recommend that those new to Git avoid git pull: it's full of traps for the unwary, and you will have more problems than if you just use the two separate commands yourself. We literally can't run git pull here, but we don't have to: all git pull does is run git fetch to get commits from your upstream remote, and then run git merge to merge those commits into your current branch. You now ran git pull and got a complaint. $ echo 'add extra line to readme' > README $ echo our new file X is different from his > X We can git add the README change, or not git add it, whichever we prefer this part will make no difference. Let's also modify README: we'll need this to make git stash do anything. Let's make a new file and fail to git add it. Now we are ready to go back to you being yourself. $ git commit -m 'new file X on branch other' We can't make a remote-tracking branch this way (I could do it by cheating) so let's just use a regular branch: $ git checkout -b other Now let's make your co-worker's branch, which you would eventually bring into your repository as origin/master. $ echo demo failure to save file in stash > README (These commit messages are terrible, by the way.) $ mkdir tt cd tt I start by making a one-commit repository with a master branch, with just a README file. My guess is that you never git added the file in the first place. But the thing is, we don't either! We can only guess. Of course, the point of your question is that you don't know quite how you did this in the first place. It’s possible to specify the stash too just find the index number of the stash you’d like more details on and run: git stash show this example, we’d be looking at the third most recent stash.It would help if you showed, step by step, exactly what you did, or-even better-provided a minimal, complete, verifiable example (also known as an MVCE).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |