1. 程式人生 > >Git上傳GitHub常用命令

Git上傳GitHub常用命令


git config --global user.name 'lanyu96'
git config --global user.email '[email protected]'
//設定SSH key
cd ~/.ssh  //檢查是否已生成金鑰
ssh-keygen -t rsa -C "[email protected]" //生成key
C:\User\zhou\.ssh(zhou為電腦使用者名稱) id_rsa.pub
將ssh key加入到github裡

git status
git add hello.py
git add . //新增所有檔案
git commit -m '提交描述'

git remote add origin 倉庫地址 //新增倉庫地址

git pull --rebase origin master //程式碼合併

git push -u origin master  //上傳原生代碼
//刪除雲端檔案,本地保留
git rm --cached -r filename 
git commit -m "註釋" 
git push -u origin master 


touch test.php //建立檔案
rm test.php //刪除檔案
git rm test.php //從Git中刪除
git config --list //檢視配置清單

git clone http.... //從Github中將資料下載到本機

git branch test //建立分支

git checkout test //切換分支

git remote add origin https://***********    //與遠端分支關聯

git push origin test  //將分支上傳