還是直接貼教程吧:https://git-scm.com/book/zh/v2
如何把本地idea上的項目上傳到github上:https://www.cnblogs.com/gougouyangzi/articles/9429280.html
1.owner在遠程庫更新了分支,但是在我這里git branch -a查看不到新的分支,
解決辦法:git fetch origin --prune 更新一下分支信息,然后再git branch -a就能看到新的分支了~
2.提交代碼到遠程庫:
git status # 查看本地代碼狀態
git add . # 添加修改代碼到緩存
git commit -m "一些信息" # 提交
git push 倉庫地址 # push進去了!
3.切換分支:
git checkout -b 分支名 #新建分支
git branch -a
git checkout 分支名
4.多人協作的工作模式通常是這樣:
-
首先,可以試圖用
git push origin <branch-name>
推送自己的修改; -
如果推送失敗,則因為遠程分支比你的本地更新,需要先用
git pull
試圖合並; -
如果合並有沖突,則解決沖突,並在本地提交;
-
沒有沖突或者解決掉沖突后,再用
git push origin <branch-name>
推送就能成功!
5. 如果git pull
提示no tracking information
,則說明本地分支和遠程分支的鏈接關系沒有創建,用命令git branch --set-upstream-to <branch-name> origin/<branch-name>
。
5.將本地代碼與遠程庫關聯
先要在github上新建一個項目
然后 git push -u 項目地址 分支名稱