I want to modify the index of one (text) file without having to change the working tree file state. Is this possible?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
yes, you can use the --work-tree option on the git level of any (this is not actually true. It should work on any but there are edge cases) command:
Yes, you can explicitly stage a blob at a particular path with
git update-index
.You will also need to use
--add
if the path is a branch new file.If the file that you want to stage is a blob that doesn't yet exist in the git repository then you can store a new blob in the git repository with
git hash-object
, e.g.:or
You can then stage the blob as above.
Another take on "changing file in index without altering working dir" is to apply a patch to index only. This is often the way GUI git clients stage only selected lines from a given file.
You start out by (if you want) clearing out the changes from index for that file:
Then extracting the full patch for it
Edit the patch file to include only the changes you want to apply, and apply just the edited patch:
See: