git clone -mirror vs. git clone -bare
git clone --bare
Similar to git init --bare,
when the -bare
argument is passed to git clone,
a copy of the remote repository will be made with an omitted working directory. This means that a repository will be set up with the history of the project that can be pushed and pulled from, but cannot be edited directly. In addition, no remote branches for the repo will be configured with the -bare
repository. Like git init --bare,
this is used to create a hosted repository that developers will not edit directly.
git clone --mirror
Passing the --mirror
argument implicitly passes the --bare
argument as well. This means the behavior of --bare
is inherited by --mirror
. Resulting in a bare repo with no editable working files. In addition, --mirror
will clone all the extended refs of the remote repository, and maintain remote branch tracking configuration. You can then run git remote
update on the mirror and it will overwrite all refs from the origin repo. Giving you exact 'mirrored' functionality.
You can import your existing Git repository into an empty repository in Bitbucket. When you do this, Bitbucket 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 Bitbucket 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.bitbucket.domain:7999 /yourproject/repo.git).
Add Bitbucket as another remote in your local repository:
cd old-repository git remote add bitbucket https://username@your.bitbucket.domain:7999/yourproject/repo.git
Push all branches and tags to the new repository:
git push --all bitbucket git push --tags bitbucket
Remove your temporary local repository:
cd .. rm -rf old-repository
Không có nhận xét nào:
Đăng nhận xét