使用GitHub
- 在 GitHub 上 Fork 任意开源仓库,自己拥有 Fork 后的仓库的读写权限。
- clone Fork 后的仓库,进行修改,然后 push 到自己 Fork 的仓库。之后就可以 pull request 到开源仓库。
远程仓库
- 创建SSH
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了。
- 关联远程仓库
关联
git remote add origin git@github.com:michaelliao/learngit.git
推送
git push -u origin master
首次推送的时候加 -u 参数,推送master分支的所有内容。之后再 push 就可以不用 -u。
https://zhuanlan.zhihu.com/p/42929114
动图展示 10 大 Git 命令
Linux 使用 Git
Fork 项目
fork 项目后 clone 完自己 fork 的项目。
# 查看当前项目关联的远程仓库git remote -v# 关联源项目git remote add [name] ssh://git@github.com/SOURCE-PROJECT.git# 删除远程关联git remote rm [name]# 拉取更新git fetch [name]# 同步更新内容到本地对应分支git merge upstream/master
ignore 已经 push 的文件
# 先去掉所有的 track 有时候可以加 -fgit rm -r --cached .# 再加入 trackgit add .# commitgit commit -m 'update .gitignore'
