Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to commit a single staged file?

Tags:

git

git-commit

I have staged two files file1.js and file2.js but I only want to commit file2.js. How can I do this?

like image 405
mrfr Avatar asked Aug 28 '17 07:08

mrfr


2 Answers

No need to unstage file1.js (assuming you want to keep the changes in this file staged for the next commit), just enter

git commit file2.js

to only commit the changes recorded in file2.js.

like image 81
piarston Avatar answered Sep 27 '22 20:09

piarston


Simplest solution: unstage the other (git status tells you how, git reset).

like image 34
Marcus Müller Avatar answered Sep 27 '22 20:09

Marcus Müller