How to commit one file at a time

Just started using Source Tree. Finding it slightly confusing, there's no documentation anywhere telling you how to use this. Be helpful if there was.

When I added files to be staged in the index, how do I commit just the individual files? Because when I try to commit one file out of the host of files in the index it tries to commit the whole lot. I just want to commit the one. But I still want all the other added files to sit in the index for now, so I can add personal commit comments to each single file or multiple lot.

Also is it possible to add and commit a file that is not yet added in one go?

3 answers

1 accepted

A couple of ways to do this:

  1. Right-click a single file (or indeed any file selection) and select 'Commit'
  2. Open the commit dialog any way, and change the 'Commit mode' to 'Commit all changes from selected files in the working tree'. Check the files you want to commit (staging doesn't matter) and click OK.

Also note that if you don't like to use the staging mode of committing in git, go into Preferences > Git and uncheck the box 'Use the staging area'. From then on the commit mode will always be based on selected files and not the staged changes.

unchecking 'Use the staging are' worked perfectly. Now I can commit individual files where before all files in the staging area gets committed altogether and no way of unticking them.


Thanks

0 votes

It's not really a SourceTree problem here - if a file is staged in git then it gets committed. If you only want to commit one file,than only add that file - if you've already added the file to staging then remove them form the staging area using the remove button before pushing.

i don't use sourcetree often, so don't know the answer to your second part.

Git allows to commit certain files, even if they or others are staged.

Yes exactly Git allows you to commit certain files even if they're not staged. But how the hell do you do this in Source Tree??!

I haven't found a way to do that with SourceTree. But with smartGit.

Can't believe this killer app can do so many things yet can't do a simple job of just committing individual items.

Git allows to commit certain files, even if they or others are staged.

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

244 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot