码迷,mamicode.com
首页 > 其他好文 > 详细

Git常用

时间:2018-03-02 20:39:01      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:tps   push   rem   远程分支   out   dos   class   自动生成   test   

Git

第一次使用
从origin上clone代码
Eg:
cd myGitProj
git clone o2o-business-admin
本地会自动生成和origin/master相同的master

git pull origin dev_dosh:dosth
//git pull <远程库名> <远程分支名>:<本地分支名>
//从远程dosth分支拉代码到本地dev_dosh分支并merge

git checkout origin/remoteName -b localName
获取远程分支remoteName 到本地新分支localName,并跳到localName分支

git branch
//可查看当前分支处于master


git checkout -b dev_dosth
//创建并切换到dev_dosh分支,该分支与当前分支(master)相同

...modify somefiles...

git add.
git commit -m "what I did"

git push origin dev_dosth:dosth
//git push <远程主机名> <本地分支名>:<远程分支名>
//在远程创建dosth分支并将本地dev_dosth分支内容merge上去

test my modifition

gitlab上提交merge request

上线后可删除分支

 


第二次用
git checkout master
git pull

 

 

 

//git "undo" cmd

add前撤销所有改动
git checkout .
撤销sfile.txt的改动
git checkout -- sfile.txt

撤销add
git reset filename

撤销commit
git reset oldCommitId

抛弃当前合并冲突的处理过程并尝试重建合并前的状态
git merge --abort

 

git 合并多个commit
git rebase -i commitId
fixup/squash/pick/……
https://www.jianshu.com/p/964de879904a


commit后、merge到master前撤销对file的改动,使其恢复到与master相同
git rm --cached file

 

https://www.jianshu.com/p/67f20d19605a

Git常用

标签:tps   push   rem   远程分支   out   dos   class   自动生成   test   

原文地址:https://www.cnblogs.com/peanutk/p/8494441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!