Use GitHub

Concept Map


If you have the project to share then don't add README file.
If you want to create a new project then add README file and you can clone it.

To see all the current remotes %git remote
If don't have any remotes yet then the output will be empty.

v stands for verbose and means that git remote will output more information



Add the repository on GitHub as a remote %git remote add  remote_name   URL
(If you only have one remote, it's standard to name it origin)

Send changes to the remote  %git push remote_name local_branch_name
The branch was pushed on GitHub
Git push takes two arguments.The remote I want to send changes to and the name of the local branch that I'd like to push.

you can see know your branch have the remote branch



Get remote the project's changes to the local project %git pull remote_name local_branch_name


Copy other's project on GitHub use Fork
 click Fork Button
注意:可以直接更改你的Fork中的 master 分支,但是,在协同构建公共版本库时,标准的做法是在Fork内的非 master 分支中进行更改。这样一来,可以轻松让你的 master 分支与原始版本库的 master 保持同步,并在准备好时将 master 中的更改合并到分支中。
Windows 用户请注意:随着故事的发展,它已经超出了 Windows 的路径长度限制。如果你在克隆时遇到错误,可以通过修改配置设置来解决它。请在 git bash 中运行此命令:git config --system core.longpaths true


Update the local copy of the remote %git fetch remote_name


merge the remote master and local master %git merge local_branch  remote_branch

diff between local_branch and  remote_branch
merge has some conflict
open the file and fix it
add and commit

Update the local copy of the remote and merge with local master
%git pull origin local_branch
(git pull origin master = git fetch origin + git merge master origin/master)

當使用pull以後%git branch -a 才會出現remotes/origin/master資料夾
Use Pull requests merge the branch on GitHub

can use edit to change where you want to merge


在發生conflict後merge完成不用add直接commit

對fork整體實作的流程



參考資料:
https://classroom.udacity.com/courses/ud775/lessons/3105028581/concepts/30736788930923

No comments:

Post a Comment