The unnecessary complexity of Git

Git is one of the greatest distributed version control system and EGit will pave the road to success for Git in the Eclipse world.

But some things make the usage of Git difficult for new starters. I would like to highlight one particilar case; how to add files to the index. The approach differs based on the situation. New files, deleted files and already commited files are treated differently. In my opinion Git is missing one command to add all changes to the index including deleted, changed and new files. Even better git should have a commit command which add everything to the index and commits it. Experts may want finer control but in my opinion this missing option makes it hard for new starters.

Perhaps git will add such a feature in the future, in my humble opinion the power of a complex workflow should not be payed with the lack of simplicity.

The following command will add everything to the index except deleted files.

git add . 

Unfortunately IMHO there is not “git add .” for removed files. You can not tell git to add all files which are deleted to the index via wildcards. The following will not work, you need to specify the files individually.

git rm . 

The starter may think I just use git commit -a to do all this adding and deleting. Unfortunately this will only add deleted files and files which are already commited to the index. New files are not included.

git commit -a -m "message"

If you want always to add your deleted files and as well as stage files what are already commited you should use the following command. This will not add new files to the index. Thanks to Heath Borders for the clarification on this command.

git add -u . 

I hope this helps, at least I got stuck for a while in these suble but important differences. Handling this example and much more can be found in my Git Tutorial.

Btw. please don’t get me wrong I like having all these options but in addition to these option I believe git would be easier if it had one “add-it-all” option.

You find me also on Twitter .

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse and tagged . Bookmark the permalink.

5 Responses to The unnecessary complexity of Git

  1. Sebastian says:

    I guess git add -A will be your friend.

  2. David Carver says:

    As Sebastian said, I think git add -A will be your friend.

    The complexity is not in git itself (it is actually blindingly simple), but from the fact that the workflow patterns it allows are less restrictive than CVS or SVN. Plus, amazingly enough, many programmers today do not want to venture into the command line relm. If a GUI doesn’t do it for them, they want nothing to do with it. Not saying that is your case, but it is a sad reality.

  3. Lars Vogel says:

    @Sebastian Thanks for the tip.

    @David: I don’t agree that git is blindingly simple. It has powerful options and has been greatly simplified compared to the first versions but I think this path should be continued.

  4. Jens vP says:

    @David: Over the years, IBM Visual Age and Eclipse taught me _not_ to use the command line or other tools which modify files in the workspace folder, as the IDE’s metadata and caches are usually not updated, which leads to inconsistency and corrupt workspaces.

  5. Jan Köhnlein says:

    I am using a graphical tool (gitx, gitk etc.) to stage / commit files. That allows to revise and pick changes individually, no matter if it’s a delete, add, or modify. IMHO, the command line does not provide enough overview for that kind of revision. I hope for eGit to implement rebase soon, so I don’t need any additional tools.

Comments are closed.