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,
Defozo
The safest way to do this is to create a new repo on the server, clone the empty repo into a new folder and copy/move the existing files into that.
So it can't be done the other way? It smells to me like a lack of functionality. Anyway, thanks for the answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also do a git init in the existing folder: http://git-scm.com/docs/git-init and then set a remote and push it to the server. Since the remote repo has to exist when you push your changes, I think the above method is more straightforward / less error-prone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This would also be my preferred method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a fair argument. Feature requests can be made at jira.atlassian.com. I recommend posting a link to your FR here (as an answer) to help like-minded individuals find it and vote it up.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the easiest way to do this:
Sourcetree comes with git.
1) Add the path to GIT to you environmental path variable so git.exe can be found.
( Windows example: c:\Users\UserName\AppData\Local\Atlassian\SourceTree\git_local\cmd\)
2) Open the windows cmd line and navigate to the directory you want under source control
(after adding the path if you have the cmd line open you must close and open it to refresh it)
3) type git init and press enter.
4) Now the repository is a GIT Repo! yea!
5) In SourceTree goto "Add a repository"
6) Browse to your repository
7) The repo should be a Git Repo! Yea!
9) Press "Add" and your done.
The whole trick is to initialize the repo using Git and you don't need SourceTree for that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does not compute:
Say goodbye to the command line - simplify distributed version control with a Git client and quickly bring everyone up to speed."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
say goodbye to the GUI has a nicer ring to it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Feature request here https://jira.atlassian.com/browse/SRCTREEWIN-3126
I made it for the Windows version – not sure if it is appropriate to make a duplicate for the Mac version, or if there is a better way to specify platform-independent features.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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."
:(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Crazy....
This is an issue existing since years now, also for ALL other git IDEs.
I don't want ti fiddle around with magic spells in the commandline. I even don't want to know where the folder is or whatever.
I want to register on bitbuckert, right click on a folder to add it to git, and forget about it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I may as well just save projects in my dropbox folder, someone has seriously misunderstood the entire point of a GUI here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't believe this feature has been requested 3 years ago and it's still not a thing. Yes, you can do it in git, but the whole point of using SourceTree is removing the need to go to terminal. For more advanced features I understand the need of git, but this request seems common and basic enough.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 init
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In case anyone is still unable to do this and wishes to put a Unity Project on GitHub:
Open the Projekt, go to the AssetStore and search for "GitHub for Unity". The right one should be the first, you can recognize it by it being free und directly from GitHub. Download and install it.
Go to the "Window" tab and click on GitHub.
Log in, the button should be in the top right of the panel.
In the panel under the tab "Changes" select all and commit.
In the top press push.
Your project is now on GitHub. You could keep using GitHub for Unity.
But if you want to keep using SoureTree you need to delete the project from your PC (or rename it to be safe), and use SoureTree to redownload it.
I hope I could help someone, cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have an existing project
Step 1: Switch to your repository's directory
cd /path/to/your/repo
Step 2: Connect your existing repository to Bitbucket
git remote add origin https://username@bitbucket.org/username/reponame.git
git push -u origin master
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To me, the point of this request is a way to do it without having to go to the command-line. If you have to go to the command-line all the time, why use a GUI? Without getting into the larger arguments, this seems to me to be one of the fundamental and fatal flaws of nearly all *nix based tools, is their ultimate reliance on having to use a command-line tool to do anything beyond trivial work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice .... giving up before I even start with this product...will stick with VS plugin arg....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked for me, starting with a folder with files on my local computer. Make a test first if you are unsure if this will work for you. There probably is a better way to do this, but I couldn't find it.
git init
git add --all
git commmit -m "Initial commit"
git remote add origin https://<yourname>@bitbucket.org/<your_id>/<repository>.git
git push -u origin master
You should now be able to change, commit and push in SourceTree and not need the command line anymore. Make sure your Authentication is correct. See Options/Authentication, for me "OAuth" and "HTTPS" seemed to be the right kind, although I don't know what they mean really.
If there is a red exclamation mark on Remote, then go to Settings, Remote, Edit, change from Generic Account to your account. Not sure why this would happen, but everything seems to work fine with committing and pushing.
Unity: Force use of text files for assets, since otherwise they cannot be tracked by git: Edit/Project settings, select Editor, under Asset Serialization choose Mode = Force text
Unity .gitignore: https://www.indie-games.dev/tutorials/git-version-control-for-unity-using-bitbucket-and-sourcetree/
See also: https://www.atlassian.com/git/tutorials/setting-up-a-repository
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This still seems to be missing. I have a complete base of source code that I simply want to 'add to a repository' and start sharing with other workers. I should be able to just drag and drop that whole folder on to the UI and have SourceTree know what the heck I'm trying to do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure your local directory is already under git control (if not, then do it: git init etc.)
Create new repository via left command bar from your account (https://bitbucket.org/repo/create?owner=YOUR_IDENTITY). Next you get simple instructions of how to upload your local git (https://bitbucket.org/YOUR_IDENTITY/NEW_REPO_NAME/src):
Step 1: Switch to your repository's directory
cd /path/to/your/repo
Step 2: Connect your existing repository to Bitbucket
git remote add origin git@bitbucket.org:YOUR_IDENTITY/NEW_REPO_NAME.git
git push -u origin master
Control the result (https://bitbucket.org/YOUR_IDENTITY/NEW_REPO_NAME/src/master/)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
git init
git add --all
git commit -m "Initial Commit"
git remote add origin https://username@your.bitbucket.domain:7999/yourproject/repo.git
git push -u origin master
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is still an issue. I am trying to add Git to my existing development environment. We currently have developers accessing source code from shared folders on development servers. After they complete code changes, they save the changes back to one of the dev servers, and then test their changes on the dev server via a browser. Moving initial test to their individual PCs is not an option at this time.
I just want a code change made by a developer, pushed through Sourcetree to BbServer, to end up in the existing folder on the existing server for the product the developer is working on. Right now, the change stops at BbServer, and I have to perform a "pull" on the server, to get the change from BbServer. I do not want to set up a scheduled task to do this, I do not want to use hooks, webhooks, add-ons, etc. to achieve this. I just want to be able to tell BbServer to use the existing folder, and not a clone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i guess you can 1. create a new project in empty folder, 2. move the .git to your existing project, 3. open the existing project in Sourcetree.
creating repository in existing folder is something like headphone jack for iphone, or food in communism country. They insist that you don't need it but you are needing it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.