一.常用git命令
注意:以下将"<分支名>" 直接替换为分支名就行
1.git pull 拉取当前分支最新代码
git pull #git pull是拉取所有分支的最新代码,默认用的是fatch+merge的方式
#我们一般更新代码要用rebase的方法
git pull --rebase origin <分支名>
也可以用merge的方式更新代码
git pull --merge origin <分支名>
2. git push 将当前代码push到当前分支
git push origin HEAD:refs/heads/<分支名>
3. git reset
#1.将已经commit,但是没有push的提交,重新回到工作区域;就是将已经commit的代码回到没有commit状态
git reset --soft HEAD^
#2. 回到上一笔提交;
git reset --hard HEAD^
4. 切换分支
#1. 切换分支:
git checkout <branch-name>
#2. 拉取远程分支为<branch-name>的代码到本地分支<local-branch-name>
git checkout -b <local-branch-name> origin/<branch-name>