Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Visual Studio 2015, how to commit only one file?

What I've tried: I don't recall to have an issue when in VS2013. When in VS2015, I've tried the context menu inside one code file or right clicking just that file from Solution Explorer, yet it includes all changed files.

I've also tried filtering and that doesn't help narrow down the checkin.

like image 896
Ryan Betker - healthNCode Avatar asked May 04 '16 13:05

Ryan Betker - healthNCode


People also ask

Can you commit only certain files?

To literally commit only those files, even if other changes have been staged, the second example ( git commit [some files] , which implies the --only switch) should be used. The first example ( git add [some files] followed by git commit ) will also commit any other changes which had been staged.

Can I commit just one file git?

Normally we commit to git, all files are going to git but in your scenario push only single file git. For this, you have to run specific command to push the only single file to git. Above all commands are related to push the only single file to git but sometimes we want to push only two files to git in a single commit.


2 Answers

If you're using Git with Visual Studio 2015, from Team Explorer, right-click on just the file(s) you want to commit and select Stage.

Now you'll have a new section above Changes called Staged Changes that only contain the file(s) you want. Type in your commit message and then select Commit Staged. Everything else will still be untouched under Changes.

like image 59
Jay Adams Avatar answered Sep 22 '22 05:09

Jay Adams


OR, or, you can always do this in git bash(windows). Make sure you open git bash in your project folder and type following commands:

$ git add fileToCommit.extension $ git commit -m "This is my commit message" 

Push when you are done:

$ git push 
like image 23
Igor Pavlichenko Avatar answered Sep 23 '22 05:09

Igor Pavlichenko