Gregsen
Gregsen

Reputation: 471

Git lets me commit unstaged changes

I've been reading some tutorials on Git and each says, that tracked files need to be added, before I can commit them. I can either use git add <file> or git commit -a <file>. I can however just use git commit <file> omitting the -a switch and it will still commit my changes. I am just wondering if this is normal behaviour or not. I am using Ubuntu 12.10 with git 1.7.10.4

Upvotes: 1

Views: 76

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382274

You willingly typed the path to your file. Why would git require that it's added before ?

BTW there's a doc in command line, you'll see it's normal by typing git help commit :

DESCRIPTION
  Stores the current contents of the index in a new commit along with a log message from
  the user describing the changes.

  The content to be added can be specified in several ways:

         ... snip...

  3. by listing files as arguments to the commit command, in which case the commit will
     ignore changes staged in the index, and instead record the current content of the
     listed files (which must already be known to git);

Upvotes: 3

Related Questions