Reputation: 41
So, for example, if I have a file index.html and change some lines and execute git add index.html
. Then I will again modify index.html but will not stage change. And do git commit
and git push
. Will my last changes applied in commit
/push
?
Upvotes: 2
Views: 3458
Reputation: 194
"git commit" works on files that are in staging area. So, your first change to index.html which you staged will be part of your commit and push. Remember the name is Staging Area, a separate place where you want to accumulate all your changes that you want to commit.
Now, lets try to understand what happens when you do your second change to index.html If you do "git status", you will see that now index.html is listed both in staging area and also in modified files. And if you do "git diff" on index.html, only your second change will be shown as diff. And, if you want to include this change also into your commit, you just to "git add" on this file again. So, what happens to the already staged file. It will be updated with a file which has both changes.
Upvotes: 1
Reputation: 4895
No, your last changes will not be commit and push to git server. Only the files where are in staging area (git add
) would be committed and can be pushed. If you change a file and do not add to the staging area (git add
), then you don‘t commit or push it to the git server.
If you want to add the last changes also and push it to the server, just git add
again and then commit and push it.
Upvotes: 4