git-it 教程,一些git知识点。

https://github.com/jlord/git-it-electron#what-to-install 

一个git使用教程 


看刚才改变的文件的区别。

git diff:

Add GitHub username to Git

添加你的用户名到你的Git配置: (一次性的,所有仓库都是这个名字)

git config --global user.username <USerNamE>

再核查一下:

git config --global user.username


git remote add origin https://github.com/chentianwei411/hello-world.git
git push -u origin master

把master分支推到远程仓库origin。

-u的意思是设置upstream ❓不明白。

提示:

设置URL给一个远程仓库, 改变一个远程仓库url

git remote set-url <remoteName> <URL> 

拉:

git pull <remoteName> <branchName>

推:

git push <remoteName> <branch> 

增加一个远程仓库:

git remote add <remoteName> <URL> 


Fork and Clones

fork到你的GitHub账号,然后clone到你的电脑,你的电脑可以链接2个远程仓库,自己的和fork别人的仓库。

可以从别人的仓库pull变化的代码。也可以push request,请求合并。

  1. fork
  2. git clone <自己的url>
  3. 链接到原始的仓库。别人的那个仓库。git remote add upstream <别人的仓库URL>

origin https://github.com/chentianwei411/patchwork.git (fetch)
origin https://github.com/chentianwei411/patchwork.git (push)
upstream https://github.com/jlord/patchwork.git (fetch)
upstream https://github.com/jlord/patchwork.git (push)

Branch 

接着上面链接了远程仓库后,master变成了gh-pages❕

输入:

patchwork ⮀ ⭠ gh-pages  git status

On branch gh-pages
Your branch is up-to-date with 'origin/gh-pages'.

Github将自动服务和静态主页网页在branch中,叫做gh-pages。这个免费的服务是GitHub Pages。既然你forked创建了一个网页,它的主要branch是gh-pages,代替了master。


改一个分支的name:

git branch -m <newBranchName> 

上传一个变动:

git push origin add-chentianwei411 


创建一个pull request

你做了一些改动,push到fork的app创建人,并在它的Github上创建一个pull request。对方会选择是否pull. 当被pull后,在本地可以合并,并删除旧分支,还可以删除远程的旧分支。

git merge <branchName>

git branch -d <dd>

git push <remoteName> --delete <branchName> 

Pull form Upstream 

 最后,因为original 变化了。pull从original upstream

git pull upstream gh-pages 

在http://jlord.us/patchwork/ 可以看到我的名字chentianwei411

猜你喜欢

转载自www.cnblogs.com/chentianwei/p/9278363.html