简洁的想法

仁爱、喜乐、和平、忍耐、恩慈、良善、信实、温柔、节制

如何利用本地工作副本建立远程GIT库

| Comments

1, 首先备份 .git/config
打开 config , 只保留如下部分[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true


2, 回到.git同级目录执行
git remote add origin ssh://user@123.321.123.321:88888/home/user/git/neten.git

3, 再次打开.git/config
发现会变成这个样子了:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true

[remote “origin”]
url = ssh://user@123.321.123.321:88888/home/user/git/neten.git
fetch = +refs/heads/:refs/remotes/origin/

我们需要添加一个单元, 最后是这样子:[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true

[remote “origin”]
url = ssh://user@123.321.123.321:88888/home/user/git/neten.git
fetch = +refs/heads/:refs/remotes/origin/
[branch “master”]
remote = origin
merge = refs/heads/master

  
4, 登录服务器123.321.123.321, 建立远程git库
$ cd /home/user/git
$ mkdir neten.git
$ cd neten.git
$ git init —bare


5, 回到本地执行
$ git push origin master

Comments