git-add

Is it possible to use the “minimal” algorithm for interactive adding?

好久不见. 提交于 2021-02-07 20:28:11
问题 Git doesn't always choose hunk boundaries correctly, when calculating a changeset from snapshots. git diff has a --diff-algorithm option that allows some tweaking in this regard; git diff --minimal sometimes gives better results than git diff alone. Is there a way to get the same optimised changeset layout also for git add -p (which basically shows the diff hunks interactively)? It doesn't seem to allow the --diff-algorithm option. 回答1: TL;DR version git -c diff.algorithm=minimal add -p

Is it possible to use the “minimal” algorithm for interactive adding?

微笑、不失礼 提交于 2021-02-07 20:27:15
问题 Git doesn't always choose hunk boundaries correctly, when calculating a changeset from snapshots. git diff has a --diff-algorithm option that allows some tweaking in this regard; git diff --minimal sometimes gives better results than git diff alone. Is there a way to get the same optimised changeset layout also for git add -p (which basically shows the diff hunks interactively)? It doesn't seem to allow the --diff-algorithm option. 回答1: TL;DR version git -c diff.algorithm=minimal add -p

Undo multiple file and folder 'git add' [duplicate]

狂风中的少年 提交于 2020-12-29 05:18:26
问题 This question already has answers here : How do I undo 'git add' before commit? (37 answers) Closed 7 years ago . I executed git add . and now I want to revert that git add. How can I accomplish that? 回答1: git reset (which is equivalent to git reset HEAD ) will un- add (more commonly "unstage") all files. In Git, revert is used for undoing an existing commit (typically a commit that happened a while ago, or has been shared with others). If your commit has not yet been shared with others,

Undo multiple file and folder 'git add' [duplicate]

一世执手 提交于 2020-12-29 05:16:01
问题 This question already has answers here : How do I undo 'git add' before commit? (37 answers) Closed 7 years ago . I executed git add . and now I want to revert that git add. How can I accomplish that? 回答1: git reset (which is equivalent to git reset HEAD ) will un- add (more commonly "unstage") all files. In Git, revert is used for undoing an existing commit (typically a commit that happened a while ago, or has been shared with others). If your commit has not yet been shared with others,

Refresh staged files

巧了我就是萌 提交于 2020-12-24 08:09:54
问题 In git, is there any (simple) way to modify the index so that only changes to files which are already in it are added? It sounds kind of complicated, but what I want to achieve is simple. Lets say my index looks like this (slightly stripped git status output): # Changes to be committed: # modified: A # modified: B # # Changed but not updated: # modified: B # modified: C # # Untracked files: # D Some changes to B are in the index, some aren't. C is not staged at all. How can I update B in the

Refresh staged files

☆樱花仙子☆ 提交于 2020-12-24 08:06:02
问题 In git, is there any (simple) way to modify the index so that only changes to files which are already in it are added? It sounds kind of complicated, but what I want to achieve is simple. Lets say my index looks like this (slightly stripped git status output): # Changes to be committed: # modified: A # modified: B # # Changed but not updated: # modified: B # modified: C # # Untracked files: # D Some changes to B are in the index, some aren't. C is not staged at all. How can I update B in the

Same file in different locations in GIT

此生再无相见时 提交于 2020-07-07 16:00:47
问题 How to add a same file in different locations in GIT on same branch If i update in one place it should reflect in other place also Here is the flow file a.txt under directory "DIR 1" and i need same file under directory "DIR 2 " If I commit /update anything on a.txt it should reflect two places. I used symbolic links no use is there any way to get it down ? 回答1: Symbolic links are one correct way, but on Windows, you need to be careful as how you register them in your Git repo: See "Git

Git submodules : must a file located in a submodule's folder be tracked by that same submodule?

不想你离开。 提交于 2020-01-30 11:28:07
问题 I have git repo A containing submodule B. A file file.c is located inside B's folder, itself inside of A's folder as you'd expect. Question : can I track this file from A and not from B ? Does that even make any sense ? Idea is that any user of B has to add their own file.c in this specific location of B's folder hierarchy. If someone fails to do that but still adds B as submodule, B will simply mention that there is no target file upon compiling/running. 回答1: I have git repo A containing

What's the difference between Git add (ctrl+A) and Stage to Commit (ctrl+T) in the git GUI?

你。 提交于 2020-01-24 09:36:25
问题 If git add CTRL + A starts tracking changes AND stages changes to already tracked files, why should I ever use Stage to Commit CTRL + T in the git gui ? 回答1: Here's the answer to my question: CTRL + A in the GIT GUI is actually to ADD A NEW REMOTE and is not the same as GIT ADD ! In the GIT GUI, there does not seem to be any distinction between 'adding' and 'staging' , both are done by the 'stage to Commit' command: CTRL + T . And according to this: http://hoth.entp.com/2008/11/5/what-git-add

How to do 'git checkout --theirs' for multiple files (or all unmerged files)

女生的网名这么多〃 提交于 2020-01-22 05:00:07
问题 Say I have this after attempting a merge and upon entering git status : # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # added by them: myfile1.xhtml # added by them: myfile2.xhtml # added by them: myfile3.xhtml ... and I know I want to do this for each of those files: git checkout --theirs myfile1.xhtml git add myfile1.xhtml ... but there are many of them. How might I do them as a batch? 回答1: The solution for my case ended up being to simply use a