Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can I stash specific uncommitted files or is it a all or nothing deal

Greg Davis January 31, 2022

I have a lot of files that I have worked on. Is it possible to stash just specific uncommitted files or is it all or nothing? What would be the best way to only commit certain files and leave the others? Would that be just to stage the specific files and commit them?

I am using Windows 10 and version 3.4.7.

Thanks.

1 answer

1 accepted

1 vote
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2022

Hi @Greg Davis,

Welcome to Atlassian Community!

Git stash is an all or nothing command, so you cannot stash just a subset. Git commit allows you to select the files you want to commit, you just have to use git add to specify the files that you want to commit.

Greg Davis January 31, 2022

Thanks @Mikael Sandberg  Thanks for the reply. The reason I ask is that I have 12 files but I only want to commit and push two of them.

How do I do the git add in Sourcetree?

Greg Davis January 31, 2022

Can I stash the unstaged files and not affect the staged files?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2022

In Sourcetree you have the option to stage specific files, and when you commit it will only include your staged files. This is the equivalent to using git add from the command line. Have a look at Create a file, add it locally, and push it to Bitbucket for a simplified example.

Greg Davis January 31, 2022

Then when I commit the staged files, I can then stash the unstaged files?

Greg Davis January 31, 2022

So when I commit the two files, I would push them?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2022

If you want your commit to be available on the remote repository, then yes, you need to push it. There should be a checkbox that allow you to push automatically when you make your commit.

Like Steffen Opel _Utoolity_ likes this
Greg Davis January 31, 2022

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events