天天看点

Git一些使用注意事项

Git创建远程空仓库时要注意加上--shared=group

即命令:

#初始化远程空仓库:
git init --bare --shared=group

#给空仓库设置组共享:
git config core.sharedRepository group

#注意这里的group不用换成实际的组名,就直接用group.
#然后再chmod -R 775 XXX.git/ 和 chown -R git:git XXX.git/
#这样git组用户就对这个仓库有读写权限...
           

本人在网上查了很多资料,都没有说明白group不换。

再附加一些平时常用的git命令:

#git命令行操作日记:

git init #初始化一个本地仓库
git remote add origin #远程仓库地址 //连接本地仓库与远程仓库 
git commit -m "提交到本地仓库"
git push origin master #提交到远程仓库

git config receive.denyCurrentBranch ignore #解决无法push到远程仓库的问题
           
当本地文件和仓库文件冲突或者本地还没有修改完就想pull最新代码时:
1:git stash 将本地修改暂存起来
2:git pull 拉取最新代码
3:git stash pop 然后再取出你暂存的修改代码来
           

继续阅读