git-add

git stash and edited hunks

不羁岁月 提交于 2019-12-03 07:26:50
问题 I totally love git add -p and git stash but I occasionally have the following problem, which is reproduced by the following sequence of commands: git add -p my_file : then I edit a hunk manually (using e ) because the splitting that git suggests does not suit me git stash --keep-index : then I do some testing, and if the tests pass I do not commit git stash pop : now the problem occurs: the file my_file is now considered as conflicted , and git has completely messed with my edited hunk, so I

Any difference between git add . and git add --all?

核能气质少年 提交于 2019-12-03 05:40:56
问题 Is there any difference between: git add . and git add --all ? 回答1: git add --all will add the deleted file too ( removing files from index that are no longer in the working tree ), while git add . does not. For new files and files already tracked in current working tree: git add . For only files already tracked in current working tree: git add -u For new files, files already tracked in current working tree, and remove files from index that are no longer in the working tree: git add -A or git

git: How do I recursively add all files in a directory subtree that match a glob pattern?

南笙酒味 提交于 2019-12-03 04:04:10
问题 I have several .screen files inside /xxx/documentation and its subdirectories that are already tracked by Git. After modifying many of these screen files, I run git add documentation/\\*.screen —as indicated by the first example in git-add 's documentation—to stage these files, but the command fails: fatal: pathspec 'documentation/\*.screen' did not match any files Is my command bad, or does git have a bug? 回答1: It's a bug in the documentation. Quote the asterisk with $ git add documentation/

Git: Undo local changes; git add . + git rm?

与世无争的帅哥 提交于 2019-12-03 02:24:37
Need help figuring out a couple common workflows with Github. I come from a VS TFS background, so forgive me. Undoing Pending Changes Let's say I have cloned of a git repository to my local file system. At this point, the project's local files match exactly what's in the remote repoistory. Then I decided to make some changes to the code, and change the local versions of a couple files. After doing some testing, I figure out that I want to discard my local changes and revert the local files back to what they are in the remote repoistory. How do I undo these local changes, restoring them to the

How to avoid specifying absolute file path while git-add

不羁岁月 提交于 2019-12-02 18:41:59
Using git add command becomes tedious once the file path becomes lengthy. For e.g. git add src_test/com/abc/product/server/datasource/manager/aats/DSManger.java Is it possible to bypass specifying absolute file path? May be using some kind of pattern or something? I know that we can use git gui . But I want to do it using cmd line. Thanks in advance for the inputs. For unix-like systems you can always use the star to point to files, e.g. git add *DSManager.java will include all DSManager.java files git can find within your source tree starting in your current working directory. enzipher Here

Any difference between git add . and git add --all?

落花浮王杯 提交于 2019-12-02 18:10:48
Is there any difference between: git add . and git add --all ? git add --all will add the deleted file too ( removing files from index that are no longer in the working tree ), while git add . does not. For new files and files already tracked in current working tree: git add . For only files already tracked in current working tree: git add -u For new files, files already tracked in current working tree, and remove files from index that are no longer in the working tree: git add -A or git add --all 来源: https://stackoverflow.com/questions/23003118/any-difference-between-git-add-and-git-add-all

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

一笑奈何 提交于 2019-12-02 18:03:43
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? The solution for my case ended up being to simply use a wildcard in the directory path, since the files were grouped: git checkout --theirs directory_name/* git add

git add wont stage files - git cache confused?

我的未来我决定 提交于 2019-12-02 12:11:56
I have a feeling my git cache is getting confused fairly often. I work on Mac and use both git at terminal and SourceTree. I add or modify few files but I often notice that even files I have never modified in any way show as staged. This is very confusing already. However, even more confusing is that often issuing git add . to add all of the files to staging area does nothing. I have been using git for few years and have never had this before. I read all posts here on SO and none of them resolved this issue for me. I found one suggestion to clear git cache like: git rm --cached path/to/file

hg equivalent of git add -p?

白昼怎懂夜的黑 提交于 2019-11-30 16:21:54
问题 Is there a mercurial equivalent of git add -p ? Quoting from man, git-add with the option -p (or --patch) does the following: Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index. 回答1: Have a look at the record extension (which comes bundled with Mercurial). Note that since Mercurial doesn't have the concept of the staging area like git, running hg

Git add all subdirectories

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 10:32:37
问题 I'm having trouble adding a folder and all of it's subdirectories to my git repository. I realized this is a very popular question after doing some googling and I've tried each suggestion with no luck, specifically the suggestion from the man page on git-add. I even tried git add -A with no success. For simplicity sake, say I initialized my git repository as Dir1 . Then I have the following directory structure of files. Dir1/file1-1.txt Dir1/file1-2.txt Dir1/Dir2/file2-1.txt Dir1/Dir2/Dir3