Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit -m vs. git commit -am

Tags:

git

github

Seems easy but I just don't get it. I am in the root of my application.

Here is my workflow.

git add . git commit -m "added a new feature some files changed" git push heroku master 

This usually works. All my changes are pushed.

But sometimes I have a file that I change but when I push to Heroku the changes are not there for THAT ONE FILE... but for most of the files the changes are there...

But if I do

git add . git commit -am "added a new feature some files changed" git push heroku master 

Everything (all changes) are pushed to Heroku

like image 575
slindsey3000 Avatar asked Nov 09 '13 15:11

slindsey3000


People also ask

What is difference between git commit and git commit?

git commit -- takes the commit message from the given file. In the parameter you should enter the name of the file you want from your repository. git commit --only is the default mode of operation of git commit.

What is git commit for?

The "commit" command is used to save your changes to the local repository. Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command. This means that a file won't be automatically included in the next commit just because it was changed.

What is git commit vs git push?

Difference Between git commit and git push in Git. The basic difference between git commit and git push is that the scope of the git commit is the local repository, and that of git push is the remote repository. The git push command always comes after executing the git commit command.

What tense is git commit?

Your project should almost always use the past tense. In any case, the project should always use the same tense for consistency and clarity.


Video Answer


1 Answers

From the docs:

git commit -a automatically stage all tracked, modified files before the commit If you think the git add stage of the workflow is too cumbersome, Git allows you to skip that part with the -a option. This basically tells Git to run git add on any file that is "tracked" - that is, any file that was in your last commit and has been modified. This allows you to do a more Subversion style workflow if you want, simply editing files and then running git commit -a when you want to snapshot everything that has been changed. You still need to run git add to start tracking new files, though, just like Subversion.

Using the option -am allows you to add and create a message for the commit in one command.

like image 123
Davin Tryon Avatar answered Sep 20 '22 09:09

Davin Tryon