I use the latter one to split my daily work into atomic commits. If you're interested in a more comfortable way to handle this task, you may also take a look on git gui tools like LazyGit or gitui. S - split the current hunk into smaller hunks K - leave this hunk undecided, see previous hunk K - leave this hunk undecided, see previous undecided hunk As mentioned in some other answer, add -u to add untracked files also. Then you can just git stash -keep-index to stash changes. All changes to be stashed should be not staged but modified or untracked. J - leave this hunk undecided, see next hunk Add the changes to the staging area which you do not want to stash. J - leave this hunk undecided, see next undecided hunk search for a hunk matching the given regex Q - quit do not stage this hunk or any of the remaining onesĪ - stage this hunk and all later hunks in the fileĭ - do not stage this hunk or any of the later hunks in the file This is the detailed explanation of the -patch-function, which i grabbed from the developers documentation: This lets you choose one path out of a 'status' like selection.Īfter choosing the path, it presents the diff between the indexĪnd the working tree file and asks you if you want to stage Using the -patch-option is possible on different git commands (f.e. It is also possible to edit the current hunk. If the hunk seems to be too big, you even might split it. You're also able to choose a single hunk by answering the question with yes. To select a single file you'll have to decline adding hunks as long as you reach that file, then you might add all hunks from that file. Git will then show a dialog like the following, for every hunk in your possible commit: diff -git files over filesĪ hunk is a coherent diff of lines as git-diff produces it. " to discard changes in working directory)Īpp (master)$ git stash -p. (use "git push" to publish your local commits) Your branch is ahead of 'origin/master' by 29 commits. I want to stash nf and plugins.sbt and then commit everything else. The following doesn't work and the man page isn't very helpful (it appears to talk about terminal output, not actually stashing). This very promising answer, Stash only one file out of multiple files that have changed with Git?, doesn't show the usage and I'm having trouble working it out. " git stash" does this by building a temporary index file.I'm trying to figure out how to stash two specific files among many uncommitted changes. git/index.įor " git stash" to create a commit tree, files that have been changed (edited) but not yet staged with " git add" have to be added to the object store. " git add" both add a copy of a file to the object store, and sets the staging flag for that file in. Those entries contain the full path and filename and also cached metadata about the file, both filesystem metadata and git-related metadata. git/index holds a list of entries for each file in the working tree. git/logs/refs/stash contains a reflog-like chunk of metadata about the stashes before the one in. git/refs/stash contains the hash value for the commit tree that the stash created. I haven't looked into this deeply enough (yet) to understand how the one is translated into the other. The other commit tree, I've been told, is used to store a snapshot of the contents of. There are some tricky bits here, see below. One commit tree contains a snapshot of the current state of the working tree. git/index) is stored as two commit trees. the current version of the working tree and the contents of. The actual data stashed by " git stash" (i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |