iT邦幫忙

0

Git ll & Github 

Branch

在團隊協作中,不可能全部人都同時使用同一支檔案,也就代表我們需要各個擊破,這就是分支的概念

git branch

https://ithelp.ithome.com.tw/upload/images/20210523/20130419mV3hAbTUaW.png

*代表目前所在的分支

建立分支
git branch "branchName"

https://ithelp.ithome.com.tw/upload/images/20210523/20130419DqETnEm7B3.png

switch branch

git checkout "branchName"

https://ithelp.ithome.com.tw/upload/images/20210523/20130419tWcSH9Ghoy.png

當我們在分支commit之後
https://ithelp.ithome.com.tw/upload/images/20210523/20130419TSz2PUavbq.png
會看到剛剛commit的log


但當我們切換回main
https://ithelp.ithome.com.tw/upload/images/20210523/20130419z11k39taPw.png
會發現沒有剛剛branch的commit這就是分支的概念,分而治之

Branch merge

  • step1 add
  • git status
  • step2 commit
  • git log
  • step3 merge
  • https://ithelp.ithome.com.tw/upload/images/20210523/20130419pnJNYZeaz2.png

Github

先創立一個repository
https://ithelp.ithome.com.tw/upload/images/20210523/20130419ceQtj9j8Sw.png
然後複製這行網址
https://ithelp.ithome.com.tw/upload/images/20210523/20130419JfOiL2S4mv.png

回到cmd

git remote add origin <"複製的網址">
git push -u origin main 

https://ithelp.ithome.com.tw/upload/images/20210523/20130419ijNUMiv3zs.png
上傳完成之後回到Github就可以看到repository已新增好了
https://ithelp.ithome.com.tw/upload/images/20210523/20130419m4Rb7WTHaK.png


Another push way

  73 git clone https://github.com/zhangyangzhong/test.git
  74 ls
  75 cd .\test\
  76 code .
  77 git init
  79 git add --all
  80 git commit -m "login page"
  81 git push https://github.com/zhangyangzhong/test.git

Pull

git pull = git fetch + git merge

當我們今天已經團隊開發中了,有好幾位同事都在push新檔案,但你手上的版本是比較舊的這個時候系統不會讓你push上去,我們就需要先更新自己的版本才能推

git pull <"網址">

如果不想要有額外的commit

git pull --rebase

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言