Git 简易本地库建立以及分享

来源:互联网 发布:linux snmp 编辑:程序博客网 时间:2024/05/29 08:52

Git 简易本地库建立分享使用

为了在本地网络内分享自己的工作代码或者单纯是自己使用,建立一个本地的git仓库并在此基础上工作还是很方便的。

1)首先在你的代码内初始化一个自己git仓库

git init

2)然后将你的代码全部加入

git add .

3)之后加入一个commit 信息作为起点

git commit -s -m “Baseline”


至此一个自己的本地git仓库建立好了,之后有自己修改或者什么都可以通过git diff 等命令查看,自己调试代码,回退等等会方便很多。

如果想要分享给别人你的git仓库,则可在你的.git/config 内配置如下信息:

[core]

repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[receive]
        denyCurrentBranch = ignore
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = username@xxx.xxx.xx.xxx:/home/xxx/src/code         /*这里根据实际情况配置你的项目情况*/
[branch "master"]
        remote = origin

        merge = refs/heads/master


如果需要拉你代码的只需要如下命令:

git clone ssh://username@xxx.xxx.xx.xxx:/home/xxx/src/code 

然后如果有需求别人可以向你的分支提交代码,在简易环境下可以向主分支master 直接提交代码

git push origin master

当然其他操作应该也没啥问题。

原创粉丝点击