Github入門


GitHub Learning Lab
官網https://lab.github.com/courses

開源中國的在線沙箱 https://oschina.gitee.io/learn-git-branching/

Git常用命令

 1 // git在本地創建倉庫
 2 git init
 3 echo "Hello World!" > README.md
 4 git add -A
 5 git commit -m "my first commit"
 6 // 然后去Github創建一個倉庫"luren"
 7 git remote add origin https://github.com/xiaoming/luren.git
 8 git push -u origin master
 9 
10 
11 // 如果遠程倉庫更新了而本地沒同步,先pull再在本地解決沖突,之后merge
12 git pull origin master
13 git branch -a
14 git merge remotes/origin/master
15 git push -u origin master
16 
17 // 如果提示refusing to merge unrelated histories(當然你得確定是這個倉庫)
18 git pull origin master --allow-unrelated-histories
19 
20 // 如果提示 而你不想git修改你的文件,可以從全局關掉它
21 // 更多換行符設置詳見https://www.hhcycj.com/post/item/264.html
22 git config --global core.autocrlf false
23 
24 // git 推送代碼到已有倉庫
25 git add -A
26 git commit -m "add new Function"
27 git push -u origin master
View Code

 Git客戶端華為鏡像源下載

 

 注:關於Github課程

This branch has not been deployed

No deployments
 
 

Review required

At least 1 approving review is required by reviewers with write access. Learn more.
 
Merging is blocked
Merging can be performed automatically with 1 approving review.

這個合並報錯並非操作失誤,而是管理課程的人加了審核

 

所以必須仔細看,最好不要關掉這個頁面 。第三節時會在Pull Requests和你繼續教程內容

Tips:在頁面的chrome開發工具打開時 ,鼠標按住刷新鍵可以選擇強制刷新模式(不使用緩存)

此外Git還有很多功能 ,如submodule可以定義手動同步上游模塊。(微軟最新的終端項目倉庫就用了這個東西,節省了托管服務器帶寬)

 

github fork 別人的項目源作者更新后如何同步更新(直接在GitHub網頁上更新同步已Fork的倉庫代碼)

 

附上安全解決git報錯(push declined due to email privacy restrictions)

git報錯-->! [remote rejected] master -> master (push declined due to email privacy restrictions) - 小輝輝的博客 - CSDN博客
附上為本地代碼新建倉庫並推送本地代碼到遠程倉庫:

github入門到上傳本地項目 - 偷偷有碼 - 博客園

git-push到多個遠程倉庫,github,coding - mbinary - CSDN博客

Git常用命令大全,迅速提升你的Git水平 

 

 

 GitHub 第一坑:換行符自動轉換 [Windows用戶必看]

 

 

Linux中apt與apt-get命令的區別與解釋 - 系統極客

 

如何使用 GitHub? - 知乎

 

 

Windows下Git多賬號配置,同一電腦多個ssh-key的管理

Github 多賬號配置

 

git合並多個提交

如果團隊經常使用100M以上的單文件,建議看: Git LFS的使用 

 

另外,關於獲取指定commit的記錄

https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset

有趣的用法:建立靜態博客網站

   ·雖然是靜態的,但是引用一些js之后,連目錄檢索和評論功能都能擁有

https://hexo.io/zh-cn/docs/

 

 參考:https://zhuanlan.zhihu.com/p/60578464

 

 

 

 


 

git rebase -i HEAD~3
表示合並后"消滅"3個commit


生成本機秘鑰用於連接遠程服務器-簡化例子:
ssh-keygen -t rsa


如果你已經克隆了項目但忘記了 --recurse-submodules,那么可以運行 git submodule update --init 將 git submodule init 和 git submodule update 合並成一步。如果還要初始化、抓取並檢出任何嵌套的子模塊, 請使用簡明的

git submodule update --init --recursive

 


https://git-scm.com/book/zh/v2/Git-工具-子模塊

 

 

Github Actions

賬號設置里生成應用密鑰  https://github.com/settings/tokens

倉庫設置里 secrets 添加密鑰常量

然后 Actions 里配置即可(附上 Maven 發布到倉庫 package 的 例子 https://help.github.com/en/actions/language-and-framework-guides/publishing-java-packages-with-maven#publishing-packages-to-github-packages

 

附上 Maven 命令參數 -B 是批處理模式,不受用戶交互的影響

https://blog.csdn.net/qq_35893120/article/details/70207535


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM