处理自己的用户名和邮箱
# 查看自己的用户名和邮箱
git config --list
# 配置你的用户名和邮箱
git config --global user.name 用户名
git config --global user.email 邮箱
# 配置你的用户名和邮箱(想修改)
git config --global --replace-all user.name 用户名
git config --global --replace-all user.email 我的邮箱
创建 Git 仓库
mkdir [project_name]
cd [project_name]
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add 远程仓库别名 [remote]
git push -u 远程仓库别名 "master"
拉取远程仓库到本地
# 拉取远程仓库默认分支的代码
git clone [remote]
# 拉取远程仓库指定分支的代码
git clone [remote] -b [branch]
更新 .gitignore 文件
# 删除所有文件缓存
git rm -r --cached .
# 把文件添加到本地暂存区
git add .
# 将本地暂存的修改提交到本地仓库
git commit -m 'update .gitignore'
# 将本地的分支版本上传到远程并合并
git pull && git push
创建新分支并提交到远程仓库
# 先查看一下当前所在分支
git branch
# 创建本地分支并切换到新创建的分支
git checkout -b [branch]
# 把新建的分支 push 到远程,相当于创建一个远程分支
git push [remote] [branch]
合并分支
# 先切换到要进行合并的分支 a
git checkout [branch-a]
# 把分支 b 合并到分支 a
git merge [branch-b]
本地代码提交到远程仓库
# 把文件添加到本地暂存区
git add .
# 将本地暂存的修改提交到本地仓库
git commit '提交的描述文字'
# 将本地的分支版本上传到远程并合并
git pull && git push
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。