Hello, I believe this may be considered as a stupid question but I didn't find the answer. I'm brand new to GIT and SourceTree and I want to create a GIT repository in existing folder which contains my project files.
I know how to create a GIT repository in empty folder but I don't know how to create GIT repository when there are already created files.
Sorry for my English errors,
It certainly can be done the other way, as Balazs mentioned, but it becomes more complex if you are trying to push to a remote. You can create the new repository in the populated folder exactly the same as if the folder were empty. Once the repo is created, you'll need to add and commit the existing files.
This seems to me to be a very common scenario for individual and small teams and should be supported, especially when one is using Sourcetree with Bitbucket. An experimental project is deemed interesting enough to save, so one should be able to (with minimal effort) create an empty remote repo and push the local code to it as the first checkin without the hassle outlined above.
Balazs shared a hassle-free method in his comment, with the warning that there is increased risk of mistakes. Specifically that risk is, if you set a remote without checking out from it, there's a chance you'll overwrite something if the remote isn't actually empty (maybe a typo caused you to add the wrong remote).
It's not really hassle-free if it involves dropping to the command-line to do it. It also still looks like a multi-stage process (init local repo, create remote repo, set remote) when it ideally should be a single-step process from the SourceTree GUI. Shouldn't the process of securing one's source code have a low a barrier to entry as possible?
SourceTree isn't an software interface for BitBucket. Git is a decentralized VCS, which means that having a remote is not automatic. Since it's not automatic, it requires additional steps to set up. Also, you can do this in SourceTree. Use the third tab in the "Add Repository" dialog and choose the existing folder as the destination.
I mentioned BitBucket only in the context that if doing this required communication outside standard Git or Mercurial, then Atlassian's ownership of both SourceTree and BitBucket could be leveraged to accommodate this on a technical level. Since it can be accomplished (just crudely) it's a moot point. I did just try this (for both Git and Mercurial) and the following steps do work to achieve the OP's goal without relying on the kludge clone & copy approach. 1) Create new repo (third tab) to create local repo 2) Create new empty repo on server (I was only able to do this from the "clone repo" tab then cancelling the clone operation after viewing my Bitbucket Repos and creating a new repo there) 3) Add remote (required I again open the clone dialog to get the proper URL) This is still kludgey for several reasons: * create remote repo step is (can only be?) done as a side effect of cancelling a clone operation. * In documentation I've looked at, creating a local repo is described for creating a repo that will not have a remote, so it is not clear that this step will lead towards the solution * similarly, adding a remote is described as a way to take a repo that has been cloned and then moved to re-sync with an existing remote, and not as a part of creating a remote repo for an existing bit of code. * the FAQs for Sourcetree do not mention this use case, (the FAQs are slim overall) Since this procedure is, in my experience, how the vast majority of new (as opposed to forked) repos are made (from an existing project not in source control on a local disk) it really should be easily and clearly supported (as a valid feature request) in SourceTree.
wow! This is how feature requests are treated, apparently they get closed with: "This issue affects a version we no longer support...." which somewhat flies in the face of this porttion the mssion statement "SourceTree simplifies how you interact with your Git repositories so you can focus on coding."
Here's how I do it:
Create new Bitbucket private repository online in your account
Select "have existing project" option
In command line (CL) navigate to project folder and type
git add .
git commit -m “your description”.
Copy and paste code provided by BitBucket for “git remote…” in CL at project root
Copy and paste code provided by BitBucket for “git push…” in CL at project root
Enter password if asked
Check everything uploaded using SOURCE menu option in Bitbucket
Use clone option in Sourcetree to clone project to a new folder
For me, all that's now needed is to copy the source .ENV file to the new clone and it should work fine. Thereafter Bitbucket/GIT/Sourcetree should track and maintain your project.
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 ...
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot