Konstantin
Konstantin

Reputation: 3159

Adding certain files from a folder

I have a folder temp/ with ten files, but I need to git add only three of them. What is the easiest way to do so besides adding temp/ and then doing git reset for unnecessary files?

bash-3.2$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    temp/

Upvotes: 0

Views: 57

Answers (2)

Paul Hodges
Paul Hodges

Reputation: 15273

Just list them. Thanks to torek for reminding us about -u

$: git status -u
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    x/0
    x/1
    x/2
    x/3
    x/4
    x/5
    x/6
    x/7
    x/8
    x/9


$: git add x/3 x/5 x/7
$: git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   x/3
    new file:   x/5
    new file:   x/7

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    x/0
    x/1
    x/2
    x/4
    x/6
    x/8
    x/9

Upvotes: 1

gzh
gzh

Reputation: 3596

For your question, I would like to recommend you trying tig, On the status view of tig, you can easily choose files to be staged.

Upvotes: 1

Related Questions