Check in single file in Git?

My apologies if this is a silly question but I’m a VSS/VSTS guy trying to convert to Git 🙂

I cloned a repository and pulled down a load of Visual Studio projects. While working on those projects I noticed that another developer had submitted an invalid .sql file.
I fixed that .sql file for them, but am now unsure how to check in just that .sql file

  • Error on branch creation: “warning: refname 'master' is ambiguous.”
  • git checkout carries unstaged files to the new branch
  • Avoid building /refs/heads/master in TeamCity build job for Github pull requests
  • Diagnosis of git fetch/pull error
  • Unable to use Gcommit (Fugitive Plugin) on Vim when signing commits
  • Grunt install fails on azure web app deploy through deploy.cmd file
  • My code changes are all half-baked so they can’t be checked in at present.
    I have Git Extensions on my computer, and when I right click on the file in Windows Explorer and go Git Extensions -> Commit, there are lots of files referenced on the left.
    The file I want to check in has a symbol of a pencil, and the mass of other files all have a green + symbol.

  • How to change git from Chinese to English in mac
  • How can I change the highest directory in a git project?
  • What will `* text=auto eol=lf` in gitattributes do?
  • Should xcworkspace be in gitignore
  • Recovering from accidental git pull on octopress branches
  • GitLab.com Download Counter
  • 5 Solutions collect form web for “Check in single file in Git?”

    you only need to add the changes in the sql file to the index and run git commit.

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

    don’t worry about your other changes, as long as you haven’t added them, they won’t be committed (to make sure there are no changes in the index, run git reset before adding the other change)

    It’s probably safest/easiest to do it from the command line:

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

    This just commits the file foo.sql. Before the commit you can do:

    $ git status
    

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

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

    SmartGit can commit working tree changes from individual files even if other files are staged.

    With current versions of git you can also do:

    git commit <filename>
    

    This will commit everything in that file and only that file. What is currently staged to the index doesn’t matter.

    Some versions of git require additional arguments to be placed before the filename. This includes -m <message>.

    Git Baby is a git and github fan, let's start git clone.