Check single file in git?

My apologies if this is a stupid question, but I'm a VSS / VSTS guy trying to convert to Git :)

I cloned the repository and reset the loading of Visual Studio projects. While working on these projects, I noticed that another developer has submitted an invalid .sql file. I fixed this .sql file for them, but now I'm not sure how to check this .sql file

My code change is completely baked, so at the moment they cannot be verified. I have Git Extensions on my computer, and when I right-click on a file in Windows Explorer and go to Git Extensions → Commit, there are many files referenced on the left. The file I want to check has a pencil symbol, and the mass of other files has a green + symbol.

+6
source share
5 answers

you only need to add the changes to the sql file to the index and execute a git commit.

git add path/to/file.sql git commit -m 'fixed broken sql file' 

don't worry about your other changes, if you didn’t have add , they won’t be fixed (to make sure there are no changes in the index, run git reset before adding another change)

+11
source

This is probably the safest / easiest way to do this from the command line:

 $ git add foo.sql $ git commit -m "Fixed foo.sql" 

It just commits the foo.sql file. Before committing, you can:

 $ git status 

to confirm that only the required file will be committed (it will list other modified files separately, but they will not be “delivered” for the next commit).

+4
source

If you can use gitbash or something similar use git add <filename> .

0
source

SmartGit can capture changes to the working tree from individual files, even if other files are supplied.

0
source

With current git versions you can also:

 git commit <filename> 

This will commit everything in this file and only this file. What is currently placed in the index does not matter.

Some versions of git require additional arguments before the file name. This includes -m <message> .

0
source

Source: https://habr.com/ru/post/895155/


All Articles