解决本人的用户名和邮箱

# 查看本人的用户名和邮箱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.mdgit add README.mdgit 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]

合并分支

# 先切换到要进行合并的分支 agit checkout [branch-a]# 把分支 b 合并到分支 agit merge [branch-b]

本地代码提交到近程仓库

# 把文件增加到本地暂存区git add .# 将本地暂存的批改提交到本地仓库git commit '提交的形容文字'# 将本地的分支版本上传到近程并合并git pull && git push