git和github使用(二)

作者: 奔跑的Pi | 来源:发表于2015-11-25 16:06 被阅读92次

前端7班_leec

gitcat

forks

当fork一个repo时,实际上是复制了一份repo到自己github账号下。通过fork我们建立了自己所需使用的修改版本。


centralized-github

clone到本地

git clone <URLFROMGITHUB>

并且直接被自动连接到你github账号下的remote repo(fork副本)。通过(git remote add <REMOTENAME> <URL>)可以把修改pull到原始的repo。git remote -v检查remote连接。

新增branch

Understanding the GitHub Flow

branch&merge

Github Pages

github会自动发布你放在'gh-pages' branch上的静态页面。并且提供一个URL(fork后,branch名字为'gh-pages')。
1.git branch <BRANCHNAME>(branchname格式:add-username),得到一个全新的内容跟'gh-pages一模一样的分支'。
2.git checkout <BRANCHNAME>选择新建分支。
3.修改代码,推送(git add、git commit、git push);
git add -A会将新增和删除操作一起add。
git branch -M <NEWBRANCHNAME>修改分支名字。
git checkout -b <BRANCHNAME>新增並切換到新的分支branch

协作

Collaborators 是被赋予特定repository编辑权限的使用者要新增collaborators,先到repository的GitHub页面,点击Settings->选择 'Collaborators'页面->输入账号->点击add。

pull##

git pull <REMOTENAME> <BRANCH>从remote pull 更新。
git fetch --dry-run更新前检查remote是否有改动。

git pull

pull request 请求更新##

pull request

在原始repo页面下,点击pull request。


new pull request

本地Merge

1.切换到想要merge进去的branch,如:gh-pages:

git checkout gh-pages

2.告诉git 想要合并的分支

git merge <BRANCHNAME>

3.删除2中的分支

git branch -d <BRANCHNAME> or git push <REMOTENAME> --delete <BRANCHNAME>

从upstream pull

git pull upstream gh-pages

本文整理自:git-it

相关文章

网友评论

    本文标题:git和github使用(二)

    本文链接:https://www.haomeiwen.com/subject/tttdhttx.html