Git mirror a repo to specific branch

回眸只為那壹抹淺笑 提交于 2020-06-27 18:13:23

问题


our company try to fork a github project to our own git server,then we can add our own features on it. We just want to checkout a specific branch, and keep all branches and tags up to this branch, then copy(mirror ?) to our git server.


回答1:


Create the repo on your server. Elsewhere (not in the server repo), clone just the branch with

git clone --single-branch --branch branch_name github_repo_url

Tell git where your repo is:

git remote add mine your_repo_url

Then, push the branch to your repo with:

git push -u mine; git push --tags -u mine

"mine" is the shorthand name of your repo, it could be any string, replacing the default "origin".

This will gather the entire history leading up to branch_name, but no commits that are not ancestral to it.



来源:https://stackoverflow.com/questions/38027834/git-mirror-a-repo-to-specific-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!