Search code examples
gitsvngithubsourcetree

SourceTree push/pull/commit order


If I am working with a team member in sourcetree and we are working in 2 completely different areas such as me working with scripts and he works on scenes/art in unity. Say that he commits and pushes his changes and I see that I can pull them but I want to commit and push some of my script changes so he can use the scripts I made (example being out of 10 scripts I can commit and push I only want to commit 2 and push those 2). Do I need to commit everything I have at the moment even if it isn't finished to pull his changes just so I can push my 2 scripts that I need to send even though this way I would be pushing my scripts that are not even done yet?

I am a complete noob when it comes to source control and so is my team member and I really don't want to mess anything up but it seems like this process might be wrong but this is what the team member is advocating we do. I feel like I should be able to commit and push those 2 scripts without having to commit all of the other scripts that are not finished yet.


Solution

  • Use git stash. It was made for this exact purpose. If your repo is in an unclean state, but you want to checkout another branch, or pretty much do any git action, then stash is the way to go. Stash creates a commit not related to any branch which you can restore to any branch. Check the docs for more info: https://git-scm.com/book/no-nb/v1/Git-Tools-Stashing