1. # 在当前目录下clone项目仓库
    2. git clone https://github.com/xxx.git
    3. # 查看项目分支
    4. git branch
    5. # * master
    6. # 只会有一个master分支
    7. # 创建一个新的分支
    8. git branch mybranch
    9. # 查看项目分支
    10. git branch
    11. # * master
    12. # mybranch
    13. # 多了一个mybranch分支,但是当前仍在master分支
    14. # 切换到 mybranch 分支
    15. git checkout mybranch
    16. # 此时通过git branch查看能够发现已经到了 mybranch分支
    17. # 创建一个test.txt 写入hello world
    18. echo "hello world" > test.txt
    19. # 查看当前分支状态
    20. git status
    21. # On branch test
    22. # Untracked files:
    23. # (use "git add <file>..." to include in what will be committed)
    24. #
    25. # test.txt
    26. #
    27. # nothing added to commit but untracked files present (use "git add" to track)
    28. # 文件test.txt被创建还未被提交
    29. # 添加test.txt至暂存区
    30. git add test.txt
    31. # 这时运行git status 能够看到文件已经被添加
    32. # 提交暂存区内的所有更改
    33. git commit -m "这是这次commit的注释"
    34. # 查看当前分支的commit记录
    35. git log
    36. # push当前分支的更改到github
    37. # git push 而不指定分支有可能导致覆盖其他人的分支甚至是覆盖master分支
    38. # 请使用 git push origin 分支名
    39. git push origin mybranch
    40. # 第一次创建分支会提示远端服务器没有这个分支,需要执行如
    41. # git push --set-upstream origin mybranch的命令进行创建
    42. # 接下来就能到github相应的branch下提交pull request了