Git Learning
来源:互联网 发布:淘宝5金冠店铺排行 编辑:程序博客网 时间:2024/04/27 20:51
总结一下Git学习的内容:
1,normal workflow:
a. git clone
b. git checkout -b vt remotes/origin/VirtualTrunk
c. change some files
d. git commit -a -m “comments” (create a new commit id)
e. git pull --rebase (merge some changes)
f. git push (ok go to gerrit and review codes)
2. if need to change after the code review
a. change by comments
b. git add files
c. git commit --amend (make amend for last commit(such as change the log; add more change)
//tips: using "ament" will not create a new commit id.
d. git pull -rebase
e. git push.
3. some useful commands
git branch: local branches
git branch -a: all branches include remote
git status: develop branch status, such like change
git add: add the changes to snapshoot(stage)
git diff: check the changes
git diff --cached: check the change for snapshoot(stage)
git reset --HEAD: remove the changes from snapshoot(unstage)
git commit -m “comments”: commit the change from snapshoot
git commit -a -m ”comments”: commit the change without snapshoot(stage)
git checkout branch: switch branch “branch”
git checkout file: discard the changes on file
git reset --hard 8dfce76: discard the commit of “8dfce76”, delete the changes
git reset --soft 8dfce76: discard the commit of “8dfce76”, keep the changes
git push: sync the local changes(commit) to the remote(git server)
git commit --amend: make amend for last commit(such as change the log; add more change)
git pull --rebase: sync the remote to the local, with rebase option(it will try to merge the remote changes to local)
git rebase --continue: after fix the conflicts when “git pull --rebase”
git show commitid (show the diff of committed files with the old)
git stash (save current work)
4. some problems
一, 需要将两个commit进行合并
Melt change id for gerrit
Due to each push will make an new change id for gerrit, more actions need as below to make sure the new changes melt to the previous after code review:
1) Code review
2) New change: git commit
3) git rebase -i HEAD~2
|-> -i:means interactive mode
|->2:means melt previous 2 commit
interactive edit will appear:
choose the oldest commit as pick
choose the later commit as “s”
:wq (if the default edit for git is vim)
Log edit will appear:
Change log as you need: delete the new change id, keep the oldest change id
:wq
Note: change id used to map to the gerrit review tickit.
4) git push
二, [remote rejected] HEAD -> refs/for/VirtualTrunk (change 3884 closed)
Git push 碰到问题,我的办法是删除最新的commit id, 然后重新commit
git reset --soft HEAD^
git add files
git commit.
待续.........................................
- learning git
- Learning Git
- Learning Git
- Git Learning
- git learning
- Learning git
- learning git
- Git Learning
- Git Learning Notes
- Git learning-- Class one
- Learning Git(1)——概述
- Learning Source Control with Git and SourceTree.pdf
- Learning
- learning
- learning
- learning
- learning
- learning
- Cocos2d-x 3.0截屏功能集成
- VS2012 编译程序时报无法加载PDB文件错误解决方案
- VO(DTO)模式在分层架构设计中是否需要的扯淡
- C的堆栈,内存分配
- Sort List
- Git Learning
- Linux虚拟存储系统
- 自定义圆形ImageButton
- 第十三章 处理用户输入
- KVC
- django中文件下载(HttpResponse)
- 数据库中存储日期的字段类型到底应该用varchar还是datetime ?
- Android 应用签名并发布(APK-keystore)
- Codeforces Round #256 (Div. 2)A-D