I have a need to clone an existing repo into a new one. Repositories are hosted on gitlab. For now i have created a new gitlab repository, and cloned the existing repo into the new one.
upto here everything worked fine. i checked for branches using command git branch -a - it showed all remote branches.
git push -u origin --all
( it resulted in pushing only master to the new git repo.I want to understand why all the branches are not cloned into the new directory.)
I want to push all the code from existing repo to new including branches, tags and everything.
What i am missing here?
That was illustrated in " Move git repo with git clone --mirror and git push --mirror "
In your case, using git clone --mirror
:
git clone --mirror ssh://git@git.xyz.com:8888/Project/repo.git
cd repo.git
git remote set-url origin ssh://git@git.xyz.com:8888/Project/Newrepo.git
git push --mirror
Note the use of git remote set-url
(instead of remove/add)
I think you should give a try to --mirror
option, ie run command git push --mirror origin
--mirror
Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote..mirror is set.
While cloning an existing project into a new repo (using gitlab) i would suggest the following steps:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.