Git常用命令
- 各客户端生成密匙和公匙: ssh-keygen -t rsa
- 服务器创建git用户及目录 /home/git/.ssh/
- 将id_rsa.pub 拷贝到B的/home/git/.ssh/中,添加到authorized_keys文件: cat id_rsa.pub > authorized_keys
- 设置sshd相关权限
- 服务器端,创建repository目录: git --bare init
- 客户端,创建目录,然后 git init
- git clone ssh://git@xxxxxx/path/to/
- 客户端,添加或修改文件,然后 git add xxx.file, git commit -m "what modified by who"
- 客户端,添加远程repository: git remote add work_mygit ssh://git@xxxxxx/home/git/work/mygit/
- 客户端,把更改推送到服务器:git push -u work_mygit master
- 其他客户端,获取最新版代码:
- git remote add remoteworkpath ssh://git@xxxxxx/home/git/work/mygit/
- git fetch remoteworkpath master
- git status
- git log -p master.. remoteworkpath/master
- git merge remoteworkpath/master