git的这些操作,就够用了

2020-09-26  本文已影响0人  做笔记的地方

1.基础操作

git status -s查看有什么改动
git checkout -b feature/resource_form新建个分支
git branch查看分支
git add .添加文件到缓存区
git commit -m ’feat: ‘提交并写注释
git remote 查看提交名字origin
git push (origin) (feature/resource_form)
remote 分支名
选择合并的分支,进行申请

删除本地分支:git branch -d dev20181018

2.合并解决冲突

git checkout test切换test分支
git checkout -b feature/test 新建切换一个分支
git pull origin test 拉下test里的代码
git merge feature/test/channel 合并feature/test和 feature/test/channel里的代码,解决冲突
git add . 提交文件
git commit -m "Merge branch 'feature/test/channel' into feature/test”提交文件
git push origin feature/test

3.撤销操作

git reflog查看提交的历史记录
git reset —hard HEAD@{n}回退版本

4.更新本地代码

git remote -v: 查看远程仓库详细信息,可以看到仓库名称
git checkout —track origin/branch_name 本地新建分支追踪远程分支(目前没发现作用)
git branch -a 查看所有的远程分支标红
git remote update origin 更新本地分支
git checkout origin/feature-dev -b feature/dev 本地新建分支追踪远程分支

上一篇下一篇

猜你喜欢

热点阅读