1、查看远程仓库地址
git remote -v
2、查看远程分支 只显示 远程分支/ 带提交记录
git branch -r / git branch -rv
3、只查看本地分支 / 查本地和远程 所有的,无对应关系
git branch / git branch -a
4、查看本地分支 带了最近一次提交记录
git branch -v
5、查看本地分支 和对应的 远程分支。 带了本地的最后一次提交记录
git branch -vv
6、创建远程分支 git push origin (名字) 就是创建了远程分支,基于所在的本地分支创建的
git checkout -b car / git branch car 创建本地分支不切换 git checkout car
git push origin car
git push --set-upstream origin car 本地关联 远程
localhost$ git checkout -b text 创建切换本地分支
Switched to a new branch 'text'
localhost$ git branch 查看当前本地分支
master
* text
localhost$ git push 由于当前本地分支没有对应的远程分支 推送失败
fatal: The current branch text has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin text
localhost:$ git push --set-upstream origin text 创建远程分支并推送
Total 0 (delta 0), reused 0 (delta 0)
remote: run code_review post hook success
remote:
remote: To create a merge request for text, visit:
remote: http://git.xiaojukeji.com/mapkit-android/global_map_flow/merge_requests/new?merge_request%5Bsource_branch%5D=text
remote:
To https://git.xiaojukeji.com/mapkit-android/global_map_flow.git
* [new branch] text -> text
Branch text set up to track remote branch text from origin.
7、删除本地分支/远程分支
git branch -d <local_branch_name>/ git push origin -d <remote_name>
8、直接 切换远程分支,并创建本地分支
git checkout origin/text 默认远程和本地分支名字一样
git checkout origin/text -b text1 。 text 自定义本地分支名字