Github Basic Examples

xiaoxiao2021-02-28  61

仅供个人笔记用,记录查询过的代码片断和一些语法,不成系统。随遇随加,为方便修改才置顶。


branch管理

创建branch

git branch new_branch_name

检出branch

git checkout branch_name

创建并检出新的branch

git checkout -b new_branch_name

查看当前branch

git branch

带星号的就是当前branch

查看远程branch

git branch -r

查看所有branch

git branch -a

删除本地branch

git branch -D branch_name

删除远程branch

git push origin --delete branch_name

修改branch 名字

git branch -m old_name new_name

提交branch

git add . --all git commit -m 'comment here' git push -u origin branch_name

注意,-u参数只在提交新分支时使用

合并branch

假设要合并b1与b2

git checkout b1 git merge b2

查看提交历史

查看某一个文件的详细提交记录

git log -p filename

查看目前的每一行是哪个提交最后改动的

git blame filename
转载请注明原文地址: https://www.6miu.com/read-53735.html

最新回复(0)