Add all files to a commit except a single file?

前端 未结 13 873
遇见更好的自我
遇见更好的自我 2020-11-28 17:03

I have a bunch of files in a changeset, but I want to specifically ignore a single modified file. Looks like this after git status:

# modified:          


        
13条回答
  •  时光取名叫无心
    2020-11-28 17:32

    While Ben Jackson is correct, I thought I would add how I've been using that solution as well. Below is a very simple script I use (that I call gitadd) to add all changes except a select few that I keep listed in a file called .gittrackignore (very similar to how .gitignore works).

    #!/bin/bash
    set -e
    
    git add -A
    git reset `cat .gittrackignore`
    

    And this is what my current .gittrackignore looks like.

    project.properties
    

    I'm working on an Android project that I compile from the command line when deploying. This project depends on SherlockActionBar, so it needs to be referenced in project.properties, but that messes with the compilation, so now I just type gitadd and add all of the changes to git without having to un-add project.properties every single time.

提交回复
热议问题