zl程序教程

您现在的位置是:首页 >  工具

当前栏目

GitHub学习笔记

2023-09-14 09:01:04 时间
msysgit是Windows版的Git,从http://msysgit.github.io/下载,然后按默认选项安装即可。安装完成后,在开始菜单里找到”Git”|”Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!

msysgit是Windows版的Git,从http://msysgit.github.io/下载,然后按默认选项安装即可。安装完成后,在开始菜单里找到”Git”|”Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!


git config --global user.name "YOUR NAME"

git config --global user.email "YOUR EMAIL ADDRESS"

注意git config命令的--global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。


选择仓库是公开的还是私有的(只允许付费用户创建)。 选择”Initialize this repository with a README.”。 点击”Create repository”。

也可从命令行输入如下语句:
mkdir repoName
cd repoName
git init


在仓库的文件列表点击”README.md”。 点击编辑按钮,对文件作出修改,文件内容上方有预览按钮可以预览修改效果。 在”Commit changges”下方输入简单的有意义的更新信息。 点击”Commit changes”。
最后一步除了”Commit changes”之外还有” Create a new branch for this commit and start a pull request”选项,可以用此选项创建一个pull request。管理员即可点击”Merge pull request”合并结果。如果从命令行合并,步骤如下:
Step 1: From your project repository, bring in the changes and test.
git fetch origin
git checkout -b chinaeagle001-patch-1 origin/chinaeagle001-patch-1
git merge master
Step 2: Merge the changes and update on GitHub.
git checkout master
git merge --no-ff chinaeagle001-patch-1
git push origin master
On GitHub, navigate to the octocat/Spoon-Knife repository. Fork buttonIn the top-right corner of the page, click Fork.
在GitHub页面,导航到你的分支,复制分支的URL。 打开命令行,输入:git clone https://github.com/YOUR-USERNAME/Spoon-Knife。 回车,本地克隆创建完毕。 配置Git使分支与原始的仓库同步
On GitHub, navigate to the octocat/Spoon-Knife repository. 复制原始仓库的URL。

在命令行输入git remote -v并点击回车,可以看到当前配置的你的分支的远程仓库。
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

输入git remote add upstream,然后粘贴复制的URL并点击回车。
git remote add upstream https://github.com/octocat/Spoon-Knife.git

此时,再次输入git remote -v,可以看到如下信息:
git remote -v
# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

现在,就可以通过少量的Git命令使分支与原始仓库同步。
git fetch upstream
git checkout master
git merge upstream/master

The sky’s the limit with the changes you can make to a fork, including:
- Creating branches: Branches allow you to build new features or test out ideas without putting your main project at risk.
- Opening pull requests: If you are hoping to contribute back to the original repository, you can send a request to the original author to pull your fork into their repository by submitting a pull request.


Github全面学习笔记 不如看看官方的指导手册:https://guides.github.com/ 可以翻译成中文查看哦! ====================================================如何创建分支branch? 分支可以方便同时处理多个版本的代码,它是在创建分支的那个时间点上的原始分支的精确副本。