[Other doc versions]
[Doc downloads]
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 to an empty Stash repository.
On this page:
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.
Assuming you have Git installed on your local machine, then:
Initialise the project by running the following commands in the terminal:
git init git add --all git commit -m "Initial Commit"
Push your files to the repository by running the following commands in the terminal (change the URL accordingly):
git remote add origin https://username@your.stash.domain:7999/yourproject/repo.git git push -u origin master
You can import your existing Git repository into an empty repository in Stash. When you do this, Stash maintains your commit history.
Check out the repository from your existing Git host. Use the --bare parameter:
git clone --bare https://username@bitbucket.org/exampleuser/old-repository.git
Log into Stash and create a new repository (we've called it repo.git
in this example).
Locate the clone URL in the nav panel on the left (for example: https://username@your.stash.domain:7999/yourproject/repo.git).
Add Stash as another remote in your local repository:
cd old-repository git remote add stash https://username@your.stash.domain:7999/yourproject/repo.git
Push all branches and tags to the new repository in Stash:
git push --all stash git push --tags stash
Remove your temporary local repository:
cd .. rm -rf old-repository
You can mirror an existing repository into a repository hosted in Stash.
Check out the repository from your existing Git host. Use the --mirror parameter:
git clone --mirror https://username@bitbucket.org/exampleuser/repository-to-mirror.git
Log into Stash and create a new repository (we've called it repo.git
in this example).
Locate the clone URL in the nav panel on the left (for example: https://username@your.stash.domain:7999/yourproject/repo.git).
Add Stash as another remote in your local repository:
git remote add stash https://username@your.stash.domain:7999/yourproject/repo.git
Then push all branches and tags to Stash:
git push --all stash git push --tags stash
git fetch --prune origin
('–prune' will remove any branches that no longer exist in the remote) followed by the git push
commands from step 5 to update the Stash mirror with new changes from the upstream repository.