使用GitHub

  • 在 GitHub 上 Fork 任意开源仓库,自己拥有 Fork 后的仓库的读写权限。
  • clone Fork 后的仓库,进行修改,然后 push 到自己 Fork 的仓库。之后就可以 pull request 到开源仓库。

远程仓库

  • 创建SSH
  1. ssh-keygen -t rsa -C "youremail@example.com"

Shell或者Git Bash执行以上命令,一路默认回车。执行完以上命令后会在用户主目录下生成 .ssh 文件夹,和 id_rsa和id_rsa.pub这两个文件。

登录GitHub,在Account Settings,”SSH KEYS”界面,点击Add SSH Key,在key中填入 id_rs.pub 的内容,title随意。然后点击add,这样就能往Git Hub 仓库 push了。

  • 关联远程仓库

    关联

  1. git remote add origin git@github.com:michaelliao/learngit.git

推送

  1. git push -u origin master

首次推送的时候加 -u 参数,推送master分支的所有内容。之后再 push 就可以不用 -u。

https://zhuanlan.zhihu.com/p/42929114

动图展示 10 大 Git 命令

Linux 使用 Git

https://blog.csdn.net/qq_42690368/article/details/82319238

Fork 项目

fork 项目后 clone 完自己 fork 的项目。

  1. # 查看当前项目关联的远程仓库
  2. git remote -v
  3. # 关联源项目
  4. git remote add [name] ssh://git@github.com/SOURCE-PROJECT.git
  5. # 删除远程关联
  6. git remote rm [name]
  7. # 拉取更新
  8. git fetch [name]
  9. # 同步更新内容到本地对应分支
  10. git merge upstream/master

ignore 已经 push 的文件

  1. # 先去掉所有的 track 有时候可以加 -f
  2. git rm -r --cached .
  3. # 再加入 track
  4. git add .
  5. # commit
  6. git commit -m 'update .gitignore'