關於git分支的一些用法(持續更新中…)
今天,簡單瞭解了一下關於git分支的用法
場景:由於專案需要,我們團隊進行開發,各個成員完成各自的功能模組,但是在git上上傳的時候非常亂,這個時候,我們需要用到分支branch,當然這個功能只是分支的一部分功能,還有很多功能後續我會再進行深度學習瞭解。
1.首先
找到團隊的GitHub地址,把他克隆下來
git clone https://xxxxxx.xxxx/xxxx(你的專案地址)
克隆完成之後,cd進入你的專案
cd 你的專案名稱
然後,你開始開發你的功能了
2.新建一個分支
接下來,我們新建一個分支
git branch <your branch name>(你的分支名)
然後,切換一下分支
git checkout <your branch name>(你的分支名)
切換成功terminal輸出如下
Switched to branch <your branch name>(你的分支名)
我們git status
一下,看一下改動的檔案,紅色的是你修改過的檔案,
然後執行git add -f
,這時你再git status
一下,是不是發現紅色的檔案都變成綠色了。
然後執行
git commit -m "你的註釋/可以寫寫改了啥功能,或者就是什麼版本啊balabala"
commit
成功了控制檯大概如下輸出
[experiment e465517] branch
1 file changed, 1 insertion(+)
create mode 100644 hello/hello
最後,執行一下程式碼把你專案提交上去
git push origin <your branch name>(你的分支名)
成功了大概terminal顯示如下
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 311 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
To https://git.coding.net/CodeTiger_/livec_news.git
* [new branch] experiment -> experiment
至此,就全部完成了,如有疑問或者文章存在任何錯誤,歡迎指正?370555337@qq.com