天天看點

使用Git管理項目

一、 在Github上建立倉庫

使用Git管理項目

二、在項目根目錄建立.gitignore檔案

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
/.idea
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

      

、初始化git

git init
複制代碼      

四、将現有檔案添加到暫存區

git add .      

五、送出到版本區

git commit -m "本次送出的資訊"      

六、将本地倉庫和遠端倉庫進行關聯

git remote add origin https://github.com/xxx.git       

七、将本地分支推送到遠端

git push origin master      

建立新分支(建立之前需要将原本的分支進行儲存并送出)

# 建立dev分支
git checkout -b dev
# 将新建立的dev分支推送到遠端
git push origin dev      

檢視所有分支

git branch -a      

切換分支

git checkout 分支名      

通過克隆的方式擷取遠端分支

# 通過git clone擷取的是master分支
# 通過下面的這種方式可以擷取遠端的其他分支
git checkout -b dev origin/dev      

git pull 和 git push 的差別

使用Git管理項目