essay | tech | year-summary | about
日期:2018-09-13T00:00:00Z
我明明记得git的reference上有一个新手入门,教大家如何创建一个新的git server。但是很遗憾,我没找到。
我不知道我的方法对不对。反正看起来我是没有办法去验证这个方法的正确性了= =
一般git默认是ssh连接的,当然也可以本地直接连接。这步不详细叙述了,会很占篇幅。
举例子:
/mnt/e/your-folder
vi ~/.ssh/config
host git_whatever.com
HostName git_whatever.com(or 192.168.x.x)
IdentityFile ~/.ssh/your_private.key
User git
Port [不是22的情况再写]
git init
mv .git give_it_a_name.git
接下来两个方法任选其一。
方法1:然后编辑里面的cofig
vi .git/config
改下面的两个or加上下面的两个
bare = true
shared = true
方法2:敲下面两行命令
git config core.bare true
git config core.shared true
注:如果是个人的repo,这里的shared可以不设置。
git clone your_path/give_it_a_name.git
echo "test_code" > test.txt
git add test.txt && git commit -m "test init"
git push
git pull
为了节约我有限的server资源,我在需要学习一下,pull的时候,怎么不带历史纪录pull...
.git这个文件夹真的太大了。
PS:使用 --depth 1 选项并不可以。
git clone your_path --depth 1
git push --depth 1
因为这样会导致pull失败。囧。
PS2:本文结束的时候,我找到了那个教程了。[2]
[1]git reference
[2]4.4 Git on the Server - Setting Up the Server