-
查看远程分支
$ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master
-
查看本地分支
root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git branch * br-2.1.2.2 master
-
创建分支
root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git branch test root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git branch * br-2.1.2.2 master test
这个是把分支推到远程分支 : $ git push origin test
-
切换分支到test
root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git branch * br-2.1.2.2 master test root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git checkout test M jiaocheng-server/src/main/java/com/taobao/jiaocheng/server/service/cmd/GetCustomerTarCmd.java M jiaocheng-server/src/main/java/com/taobao/jiaocheng/server/util/ServerUtil.java Switched to branch 'test' root@Jayden@SHUOHAILHL-PC /f/ggg/jiaocheng (test) $ git branch br-2.1.2.2 master * test
M 表示cong 原来分支(上一次修改没有提交br-2.1.2.2)带过来的修改
-
删除本地分支 git branch -d xxxxx
root@Jayden /f/ggg/jiaocheng (test) $ git checkout br-2.1.2.2 M jiaocheng-server/src/main/java/com/taobao/jiaocheng/server/service/cmd/GetCustomerTarCmd.java M jiaocheng-server/src/main/java/com/taobao/jiaocheng/server/util/ServerUtil.java Switched to branch 'br-2.1.2.2' root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git br * br-2.1.2.2 master test root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git br -d test Deleted branch test (was 17d28d9). root@Jayden /f/ggg/jiaocheng (br-2.1.2.2) $ git br * br-2.1.2.2 master
-
查看本地和远程分支 -a。前面带*号的代表你当前工作目录所处的分支
remotes/origin/HEAD -> origin/master #啥意思呢?
在clone完成之后,Git 会自动为你将此远程仓库命名为origin(origin只相当于一个别名,运行git remote –v或者查看.git/config可以看到origin的含义),并下载其中所有的数据,建立一个指向它的master 分支的指针,我们用(远程仓库名)/(分支名) 这样的形式表示远程分支,所以origin/master指向的是一个remote branch(从那个branch我们clone数据到本地)。
这个是执行 git remote -v 的结果,看出来origin其实就是远程的git地址的一个别名。
$ git remote -v origin git@xxxx/jiaocheng.git (fetch) origin git@xxxx/jiaocheng.git (push) root@Jayden /f/ggg/jiaocheng (test) $ git branch -a br-2.1.2.2 master * test remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master
-
删除远程版本
git push origin :br-1.0.0 删除远程分支 git branch -r -d origin/branch-name git push origin :branch-name
git基本操作命令—教程(开发必会)
最新推荐文章于 2023-09-03 16:12:21 发布