问题
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