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 自定義本地分支名字