美文网首页
Git 分支

Git 分支

作者: JoinPerson | 来源:发表于2017-11-22 16:32 被阅读0次

创建分支

git branch <local-branch-name>

git checkout -b <local-branch-name> 创建一个分支并切换到创建的分支上

查看各个分支当前所指的对象

git log --oneline --decorate --graph --all

切换分支

git checkout <local-branch-name>

合并分支

git merge <branch-name>

删除分支

git branch -d <branch-name>

git branch -D <branch-name>

git branch -r -d <branch-name>        删除远程跟踪分支

查看分支

git branch        查看本地分支

git branch -a        查看本地和远程跟踪分支

git branch -v         查看每个分支最后一次提交

git branch --merged        查看已经合并到当前分支的分支

git branch --no-merged        查看未合并到当前分支的分支

获取远程分支的更多信息

git ls-remote <remote-name> 显式地获得远程引用的完整列表

git remote show <remote-name>  获得远程分支的更多信息

在克隆某个项目时改变远程仓库名(不用默认的远程仓库名)

git clone <url> -o <remote-name>

抓取远程仓库数据

git fetch [remote-name]

推送分支到远程分支上

git push [remote-name] [local-branch-name] : [remote-branch-name]

创建一个同名的跟踪分支

git checkout --track  [remote-name/remote-branch-name]

基于跟踪分支创建一个本地分支

git checkout -b [local-branch-name]  [remote-name/remote-branch-name]

设置已有的本地分支跟踪一个刚刚拉取下来的远程分支,或者想要修改正在跟踪的上游分支

git branch -u [local-branch-name] [remote-name/remote-branch-name]

git branch --set-upstream-to [local-branch-name] [remote-name/remote-branch-name]

合并一个已经跟踪的分支

git merge @{u}

git merge @{upstream}

查看设置的所有跟踪分支

git branch -vv

抓取所有的远程仓库的数据

git fetch --all

抓取数据而且合并

git pull

删除远程分支

git branch <remote-name> --delete <remote-branch-name>

变基

不要对在你的仓库外有副本的分支执行变基

git rebase [local-branch-name]

git rebase <basebranch> <topicbranch]

git rebase --onto <basebranch> <server> <client> 取出client分支,找出处于client分支和server分支的共同祖先之后的修改,然后把它们在master分支上重放一遍

更多变基操作

相关文章

  • git常用命令

    分支管理 git 切换分支 git 查看远程分支 git 查看本地分支 git 创建本地分支 git 删除本地分支...

  • 关于Git使用笔记

    Git使用分支: 查看所有分支:git branch -a 创建分支:git branch de 切换分支:git...

  • git 查看远程分支、本地分支、删除本地分支

    1查看远程分支git branch -a 2查看本地分支git分支 3创建分支git分支测试 4删除远程分支git...

  • git分支指令

    git分支指令 查看git都有哪些分支:git branch -a(包括本地分支和远程分支)git branch ...

  • 创建与合并分支

    Git鼓励大量使用分支:查看分支:git branch创建分支:git branch 切换分支:git...

  • git分支和squelize-cli相关命令

    Git鼓励大量使用分支: 查看分支:git branch 创建分支:git branch 切换分支:git che...

  • 分支

    新建分支git branch [分支名] 切换分支git checkout [分支名] 新建分支并切换到分支git...

  • git 常用指令

    分支 查看分支: git branch 查看远程分支: git branch -a 创建分支: git branc...

  • 创建与合并分支

    查看分支:git branch 创建分支:git branch 切换分支:git checkout 创建+切换分支...

  • 【操作】git版本控制流入门命令FQ#1

    查看分支:git branch -a创建分支:git branch切换分支:git checkout创建+切换分支...

网友评论

      本文标题:Git 分支

      本文链接:https://www.haomeiwen.com/subject/zyrnvttx.html