Git簡單使用
1基本命令
#克隆到本地
git clone https://gitee.com/kids0cn/Python.git
#進入目錄
cd Python
#更新遠程倉庫到本地
git pull
#寫完代碼把更改加到本地倉庫
git add . #將所有更改加到緩存
#提交更改到本地
git commit -m "xx交作業(yè)"
#推送到遠程
git push
2.分支操作
選擇git倉庫的不同分支
$git clone 倉庫地址
$git branch -a #顯示本倉庫所含有的分支
$git checkout 分知名 #選擇該分支
fork操作
fork了別人的代碼,如何保持和原倉庫同步
1.設(shè)置上游倉庫
檢查當前倉庫有沒有將源地址設(shè)置為上游
$git remote -v
origin https://github.com/Your_username/Your_fork.git(fetch)
origin https://github.com/Your_username/Your_fork.git(push)
將原倉庫地址設(shè)置為當前倉庫的上游upstream。
$git remote add upstream https://github.com/Original_owner/original_rep.git
再次檢查當前倉庫的上游信息
$git remote -v
origin https://github.com/Your_username/Your_fork.git(fetch)
origin https://github.com/Your_username/Your_fork.git(push)
upstream https://github.com/Original_owner/original_rep.git(fetch)
upstream https://github.com/Original_owner/original_rep.git(push)
2.同步上游倉庫
$git fetch upstream
3.將上游倉庫的代碼合并到自己的倉庫
$git merge upstream/master