Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #####################
- ### git
- #####################
- # 可删除一个远程分支
- git push origin :a
- # 配置 push 的默认行为 (具体可参见 git 默认行为)
- git config --global push.default simple
- * nothing - push操作无效,除非显式指定远程分支,例如git push origin develop(我觉得。。。可以给那些不愿学git的同事配上此项)。
- * current - push当前分支到远程同名分支,如果远程同名分支不存在则自动创建同名分支。
- * upstream - push当前分支到它的upstream分支上(这一项其实用于经常从本地分支push/pull到同一远程仓库的情景,这种模式叫做central workflow)。
- * simple - simple和upstream是相似的,只有一点不同,simple必须保证本地分支和它的远程 upstream分支同名,否则会拒绝push操作。
- * matching - push所有本地和远程两端都存在的同名分支。
- # 删除一个分支
- git branch -D a
- # check 一个分支 并切换
- git checkout -b a
- # 使用默认工具 解决冲突
- git mergetool
- # git fetch && git merge 理想情况下(无冲突) 会有一次自动的 merge 信息
- # 否则 则需要 解决冲突 然后 commit (有冲突的情况下 必须使用 commit)
- ##### 回滚到某个版本
- 1.
- git reset --hard 4 暂存区改变 工作区改变 领先提交
- git reset --soft 8 暂存取不变 工作区不变 提交恢复
- (git checkout master)
- git commit -m 'Reverted 5 6 7 8' 提交暂存区
- (暂存区工作区保持一致)
- 2.
- git checkout 4 (要回滚到的版本)
- git reset --soft <your_branch_name>
- git checkout master (切换回分支master 而不是commit)
- git commit -m "Revert 5 6 7 8"
- ##### 打包最近一次提交的改动文件
- git archive -o update.zip HEAD $(git diff --name-only HEAD^)
- ##### 导出某个版本的某个文件
- git show COMMIT:FILE
Add Comment
Please, Sign In to add comment