GIT基本操作

先官方下载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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值