Home > Software design >  How to add and commit with a message only one file?
How to add and commit with a message only one file?

Time:10-20

I'm working with an index, script and style files for my project, when I finished some modifications I want to add and commit with a message to each file, so I can track the changes that I made in that specifically file, how can I do that? (instead of doing git add -> git commit -m -> git add -> git commit -m -> ...)

CodePudding user response:

Let suppose I have a directory "Project". inside this I have 3 files like index.html style.css and app.js

I made some changes on each files. now I want to do separate commits for individual file. so ill do and follow this steps :

1) Open terminal / git bash
2) Navigate on Project Directory using cd command.
3) git init
4) git add index.html
5) git commit -m "commit message for index.html"
6) git add style.css
7) git commit -m "commit message for style.css"
8) git add app.js
9) git commit -m "commit message for app.js"
10) git remote add remote_name remote_url
11) git push remote_name branch_name

I hope my answer will solve your problem and let me know if your problem solved.

Note:- git add . command add all files but we don't want this that's why we are using git add filename.extension for separate file.

CodePudding user response:

Just write $git commit -am "your comment" at your prompt

  • Related