您的位置:首页 > 其它

基于本地文件或者本地Git仓库创建远程Git仓库

2012-02-16 11:05 405 查看
1, 在本地机器上 (创建本地Git仓库)

cd /extend1/data/www/kb-new

git init

git add *

git commit -m "My initial commit message"

2, 在远程服务器上 (创建空的远程Git仓库)

sudo su - git

cd ~/repositories

mkdir kb-new.git

cd kb-new.git

git --bare init

备注:本人的Git Remote Repositories都在远程服务器git用户的~/repositories目录下。

3, 在本地机器上

a, 配置刚才建立的本地Git仓库跟踪远程Git仓库

cd /extend1/data/www/kb-new

git remote add origin git@XXX.XX.XX:kb-new.git

git push origin master

b, 建立远程跟踪分支

#Switch to origin/master so you don't get any error about "fatal: Cannot force update the current branch."

git checkout origin/master

#Create the local "master" branch that is tracking the "origin/master" branch

git branch -f master origin/master

#Switch back to your "master" branch

git checkout master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐