How to avoid specifying absolute file path while git-add

前端 未结 6 758
名媛妹妹
名媛妹妹 2021-01-31 13:43

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.ja

6条回答
  •  渐次进展
    2021-01-31 14:33

    I'm not sure if I understand your question.

    To add all files (not yet added), use:

    git add .
    

    If you need to add all but one file, you cold add all, then remove the files using:

    git reset HEAD 
    

    You can also add all files in a subdirectory with

    git add subdir/
    

    One thing that I know can be annoying is when you rename files, you need to add the new filename and git rm the old name. When renaming a directory this can be annoying. This (unix only) git alias solves this problem (put it in your ~/.gitconfig file:

    [alias] ;add after this heading or create this heading if it does not exist
            addremove = !git add . && git ls-files --deleted | xargs --no-run-if-empty git rm
    

    This adds all new files and removes all deleted files and stages it to the index.

提交回复
热议问题