我們新建一個項目后,會新建文件夾滞造,進(jìn)入文件夾后運行命令
git init
初始化一個代碼倉庫
手動(自動)在文件夾下創(chuàng)建 .gitignore 文件,文件格式如下
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
運行命令
git add .
會自動添加在 .gitignore 中列出的文件
在github新建一個和我們的項目根目錄名相同的倉庫
將本地庫和遠(yuǎn)程庫相關(guān)聯(lián)
git remote add origin git@github.com:<username>/<project_name>.git
將本地庫內(nèi)容推送的遠(yuǎn)程庫
git push -u origin master
進(jìn)階:
創(chuàng)建新分支
git checkout -b 'xuji'
列出所有分支
git brach
合并主分支
git checkout master --> 切換到主分支
git merge xuji -->將xuji分支合并到主分支