简体   繁体   中英

Can I skip git add command in my next commit?

I have a file name is README.MD .

I was edited README.MD and if I want to commit README.MD if so the first I need to run

git add README.MD
git commit -m 'first commit'

And I was second edited to README.MD if so I also too run like above command. So, Can I skip git add README.md in my next commit?

This should do it:

git commit -am 'made a change'

The a flag commits all modified files since the last commit (even those that have not had git add run on).

Note: It does not commit untracked files, so you will still need to git add any new files you create, the first time you commit them.

@uvuv - no, you cannot.

git does not keep track of files, it keeps track of changes . Calling git add README.md means that you have an additional change to that file you want to commit. The fact that the file is already "tracked" (ie, there has been a previous change on it - in this case, creating it) is inconsequential.

You can also use.

git commit README.MD -m "Made a Change"

This is used when the file is already in the repository . It allows the user to write a different comment for each committed file. I find this useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM