配置SSH:

配置账号:

git config –global user.name “your name”
git config –global user.email “your_email@youremail.com

提交代码:

git s
git add .
git commit -m “提交内容描述”
git pull origin ‘分支’
git push origin ‘分支’

切换分支:

git fetch origin ‘分支’

git checkout -b ’分支’ origin/’分支’

  • 切换分支:git checkout 分支名
  • 如果切换失败:
  1. git fetch
  2. git checkout -b 分支名 origin/分支名

回退版本

在一个分支中

git reset –soft head~1
1表示回退1个版本

2表示回退2个版本

回退到某个版本

git reset —soft 4e60fa983f23ff1ed5ec99f2c0cd4c4e4bf1e1d1(version code)

冲突

别人在更新代码 push冲突时 先pull一下

git pull 出现vi编辑时 按esc 跳到命令模式shift+ :wq!(保存强制退出)

如过merge成功 git界面无异常 否者需要解决冲突

关联远程仓库

git remote add origin xxx.git

//把远程仓库和本地同步,消除差异

git pull origin master –allow-unrelated-histories