sourcetree copy file from branch

Hi folks,

I'm trying to find a way to copy a specific file from one branch to another branch.

E.g. User 1 has been working in the Feature1 branch for some time. Now user2, working in the Feature2 branch, needs a file that exists in the Feature1 branch. Is there a "smooth" way of accomplishing this?

One "dirty" way of doing it would be to copy the file on the local machine (from working directory when the Feature1 branch is checked out) and paste it into the working directory for the Feature2 branch.

Best regards,

3 answers

There is a clean and easy way to do this in Sourcetree without checking out:

  1. Select the commit
  2. Select one or more files in the commit, right-click them, and select "Log Selected". This opens a new window.
  3. Right-click the selected commit and select "Reset Files to This Commit".


User 2 can checkout feature1 and copy the file somewhere - anywhere - it can even just be to a different name in the same working directory (where it will become an untracked file).  Then checkout feature2, copy the file back to its proper place and name, and do "git add".


yes I know, that's the "dirty" way of doing it. I was thinking more of a "quick" way of doing it directly in SourceTree.


Actually, I just realized, you can do this at the git command line with:

git checkout feature2

I don't know a way to do it in SourceTree.

I am also interested how to do this in Sourcetree

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,237 views 4 2
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