Tagged sourcetree

How to commit an existing local project into Bitbucket with SourceTree

If you decide you want to commit a project you have hosted on your machine into BitBucket and you’re using Sourcetree to manage it, you’ll find that there is no straightforward way to do that. When you try to create a new Repo inside Sourcetree, it demands that the project starts in a new, empty folder. There is no option to setup a new repo from existing files. This means it’s actually stupidly impossible to commit existing project files into a fresh repository in one smooth operation.

People have posted alternative ways of getting around this but the simplest way to do it goes like this:

  1. Create a repo inside BitBucket
  2. Create a new folder on your machine which will act as a placeholder
  3. In SourceTree go through the new repository dialogs and link it to the repo on Bitbucket and the folder you created in step 2.
  4. After completing step 3 there will be a .git folder in your placeholder folder, move it to where you actual project files exist
  5. SourceTree will automatically figure out that the folder was moved, you can delete this bookmark
  6. Re-add the project by dragging the folder containing your project files and .git folder into SourceTree
  7. Now you can commit your files into BitBucket from SourceTree

It’s the easiest way because it takes advantage of the fact that .git folders can be easily moved without messing things up in SourceTree.