When creating a new repository, you can import code from an existing project into Stash. You can do this by first cloning the repository to your local system and then pushing an empty Stash repository.
Import an existing, unversioned code project to an empty repository
If you have code on your local machine that is not under source control, you can put it under source control and import it into Stash. To do this:
- Locally, change to the root directory of your existing source.
Initialise the project by running the following commands in the terminal:
git init git add --all git commit -m "Initial Commit"
- Log into Stash and create a new repository.
- Locate the clone URL in the top right (eg.: https://username@stash.atlassian.com/scm/PROJECT/repo.git).
Push your files to the repository by running the following commands in the terminal (change the URL accordingly):
git remote add origin https://username@stash.atlassian.com/scm/PROJECT/repo.git git push -u origin master
- Done! Your repository is now available in Stash.
Import a Git project to an empty repository
You can import an existing repository into an empty project in Stash. When you do this, Stash maintains your commit history.
Checkout the repository from your existing Git host. Use the --mirror parameter to include all branches and tags:
git clone --mirror
Change the remote origin in your local repository to point to Stash (change the URL accordingly):
git remote set-url origin https://username@stash.atlassian.com/scm/PROJECT/repo.git
Then push all the branches to Stash:
git push --all origin