首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Git:命令”︁的源代码
←
Git:命令
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
=Fork/工作流= 在使用git fork了其他人的项目后,这个项目就会在自己的git空间复制出来,这时如果人家的版本更新了怎么办? <source lang="bash"> git clone https://git.oschina.net/solee-linux/eova.git cd eova git remote add eova-master https://git.oschina.net/eova/eova.git git fetch eova-master git pull eova-master master git fetch origin master:tmp git diff tmp git merge tmp </source> pull=fetch+merge =分支操作= <source lang="bash"> git branch new-branch git checkout new-branch #以上两个命令等同于 git checkout -b new-branch git fetch git checkout -b local-branch origin/remote-branch git push origin local-branch:remote-branch git push remote local-branch:remote-branch git push -u origin remote-branch git branch -a git branch -d alpha-1 </source> =COMMIT记录= <source lang="bash"> git log #查看提交记录 git commit --amend #修改上一次提交日志 git show commit-id </source> 如果需要修改多次提交记录,或者合并commit,则 <source lang="bash"> git rebase -i HEAF~6 # '-i'或'--interactive'参数调用交互模式 </source> 进入编辑界面: <pre> 1 pick f50ebb6 added a secondary datasource, *** THIS MAY AFFECT PROD ENV ***, and added multi-production category service 2 pick 2bed616 updated dmp category response 3 pick 879693f added category filter 4 pick 284c5a6 added another category detail api for multi-product business 5 pick 0121db1 fixed a bug where category names is not correct in category det ail api 6 pick 24ccf25 NEG-2529: (lihaifeng) updated category detail api 7 8 # Rebase 4c79356..24ccf25 onto 4c79356 (6 commands) 9 # 10 # Commands: 11 # p, pick = use commit 12 # r, reword = use commit, but edit the commit message 13 # e, edit = use commit, but stop for amending 14 # s, squash = use commit, but meld into previous commit 15 # f, fixup = like "squash", but discard this commit's log message 16 # x, exec = run command (the rest of the line) using shell 17 # d, drop = remove commit </pre> =撤销操作= <source lang="bash"> git checkout src/main/java/Xx.java git checkout . git clean -xdf git reset --hard #撤销commit git reset <commit-id> --hard git cherry-pick <some-commit-id> </source> =初始化= <source lang="bash"> git init git remote -v git remote add osc git@git.oschina.net:solee-linux/spring-cloud-example.git git pull osc master --allow-unrelated-histories git push osc master </source> [[Category:Linux/Unix]]
返回
Git:命令
。