#第一次使用之前需要设置一下账户信息
git config --global user.name "xxxxx"
git config --global user.email "xxxxx@xxx.com"
1.从源仓库fork一份源代码作为自己的个人仓库(用于暂存自己的代码,最后用于pull request)
Master repo --fork--> Personal repo --clone--> PC
2. 克隆自己仓库代码
git clone {link}
3. 拉取更新
git pull
4. 修改后的脚本,将脚本添加到暂存区
git add {file_name}
5. 添加描述
git commit -s
6.修改后git push到自己fork的仓库上
git push -f origin master
7.在github上创建pull request
personal repo ---> master repo
8. 代码再次修改后提交,然后再次创建pull request
git add ---> git commit --am ---> git push -f origin master
扩展:
如何回滚代码:
1. 查询要回滚的 commit_id
git log
2. 查看本地与github上代码的不同
git diff
3. reset之后,HEAD就会指向此次的提交记录[本地修改会被删除]
git reset --hard {commit_id}
4. 强制推送到远端(比如远端想要恢复到哪个commit时就可以使用这个)
git push origin matser --force