先官方下载git安装,然后在开始菜单中找到控制台Git Bash
cd 、li
注意事项:
先在客户端本地clone服务器上的数据,同步到本地目录后,在对目录里的文件进行替换(替换成需要提交修改的文件),文件使用修改后,在push到服务器。
1、添加、删除远程仓库
git remote add origin ssh://preston@10.0.1.67/home/git/tt.git
查看和删除:
git remote -v
origin https://github.com/luodao236/test.git (fetch)
origin https://github.com/luodao236/test.git (push)
test https://github.com/luodao236/onceAgain.git (fetch)
test https://github.com/luodao236/onceAgain.git (push)
git remote remove test
2、克隆
git clone preston@10.0.1.67:/home/git/tt.git
二、文件的提交
1、添加文件
git add 文件名
添加整个目录
git add .
2、设置提交信息
git commit -m 'add index'
查看文件信息
git status -s
3、提交远程仓库(需提前设置好远程仓库链接,origin为添加时的名称)
git push origin master
提示错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘ssh://preston@10.0.1.67/home/git/tt.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
第二次提交需要 创建分支:
$ git branch [name]
然后push
$ git push -u origin [name]