# 在当前目录下clone项目仓库git clone https://github.com/xxx.git# 查看项目分支git branch# * master# 只会有一个master分支# 创建一个新的分支git branch mybranch# 查看项目分支git branch# * master# mybranch# 多了一个mybranch分支,但是当前仍在master分支# 切换到 mybranch 分支git checkout mybranch# 此时通过git branch查看能够发现已经到了 mybranch分支# 创建一个test.txt 写入hello worldecho "hello world" > test.txt# 查看当前分支状态git status# On branch test# Untracked files:# (use "git add <file>..." to include in what will be committed)# # test.txt# # nothing added to commit but untracked files present (use "git add" to track)# 文件test.txt被创建还未被提交# 添加test.txt至暂存区git add test.txt# 这时运行git status 能够看到文件已经被添加# 提交暂存区内的所有更改git commit -m "这是这次commit的注释"# 查看当前分支的commit记录git log# push当前分支的更改到github# git push 而不指定分支有可能导致覆盖其他人的分支甚至是覆盖master分支# 请使用 git push origin 分支名git push origin mybranch# 第一次创建分支会提示远端服务器没有这个分支,需要执行如# git push --set-upstream origin mybranch的命令进行创建# 接下来就能到github相应的branch下提交pull request了