标签:内容 upd related rac upload ddl rom color hardlink
一、问题
在github中遇到感兴趣的项目,直接克隆下来,随着兴趣越来越浓,在本地做了些修改,后来干脆想fork到自己的github仓库,又要把本地的修改提交到fork后的自己的github仓库中。这时就遇到了git仓库的迁移问题。
二、解决
先查看remote的名字
git branch -r
假设你的remote是origin,用git remote set_url 更换地址
git remote set-url origin remote_git_address
remote_git_address更换成你的新的仓库地址。
三、参考
先了解一些git的基本参数介绍
git clone --bare
GIT-CLONE(1) Git Manual GIT-CLONE(1)
NAME
git-clone - Clone a repository into a new directory
SYNOPSIS
git clone [--template=<template_directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
[--depth <depth>] [--recursive] [--] <repository> [<directory>]
--bare
Make a bare GIT repository. That is, instead of creating <directory> and placing the administrative files
in <directory>/.git, make the <directory> itself the $GIT_DIR. This obviously implies the -n because there
is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to
corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used,
neither remote-tracking branches nor the related configuration variables are created.
git push --mirror
--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.<remote>.mirror is set.
git clone --bare git://192.168.10.XX/git_repo/project_name.git
su - git
cd /path/to/path/
mkdir new_project_name.git
git init --bare new_project_name.git
cd project_name.git
git push --mirror git@192.168.20.XX/path/to/path/new_project_name.git
cd ..
rm -rf project_name.git
git clone git@192.168.20.XX/path/to/path/new_project_name.git
这种方式可以保留原版本库中的所有内容。
先查看remote的名字
git branch -r
假设你的remote是origin,用git remote set_url 更换地址
git remote set-url origin remote_git_address
remote_git_address更换成你的新的仓库地址。
第二种切换remote_url的方法更直接,直接更改.git/conf配置文件里的ip地址就行。
标签:内容 upd related rac upload ddl rom color hardlink
原文地址:http://www.cnblogs.com/myitroad/p/7636956.html