Only Adding Changes for Tracked Files With Git

Let's say that we have a Git repo where we've made a number of changes, such as:

 M www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/Configuration.java
 M www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/client/PhpMicroformatsIoHfeedParserClient.java
 M www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/client/TelegraphWebmentionClient.java
 M www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/service/CarefulWebmentionService.java
 M www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/service/WebmentionService.java
 M www-api-web/postdeploy/src/test/java/me/jvt/www/api/postdeploy/ApplicationIntegrationTest.java
?? .ignored
?? www-api-web/postdeploy/src/main/java/me/jvt/www/api/postdeploy/service/PostDeployServiceImpl.java

Let's say that we want to git add www-api-web/postdeploy, but don't want to add the newly created PostDeployServiceImpl. We would ideally use git add -p, but for argument's sake let's say we don't want to do it as there are lots of files and we don't want to go through all the changes - we know what we want to add.

The solution for this is using git add -u ${pathspec} i.e.

git add -u www-api-web/postdeploy

This will then --update the files that are already tracked by Git, no others.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

Tags

This post was filed under articles.

This post is part of the series nablopomo-2019.

Related Posts

Other posts you may be interested in:

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.