我目前正在使用Windows Github GUI,它非常酷炫且易于使用,因此我尝试经常使用它。我遇到的一个问题是,当我fork一个项目时,我不知道如何用git更新该fork。
我目前正在使用Windows Github GUI,它非常酷炫且易于使用,因此我尝试经常使用它。我遇到的一个问题是,当我fork一个项目时,我不知道如何用git更新该fork。
以下是来自http://processwire.com/talk/topic/1565-github-for-windows/帖子的详细指令,仅供参考:
在此处打开shell
”# 将原始存储库分配给名为“upstream”的远程存储库 git remote add upstream https://github.com/path_to_your_repository.git
# 获取未在本地存储库中出现的原始存储库更改,而不修改文件。 # 允许您首先进行审查。 git fetch upstream
# 将获取的更改合并到您的工作文件中。 git merge upstream/master
GitHub for Windows目前仅支持一个远程 (origin
, 它引用你的fork)。
因此,您需要手动添加一个远程仓库 (称为'upstream
') 来引用原始仓库,以便您能够从upstream
(通过CLI)拉取并更新本地仓库,使您能够使用GUI将新提交推送到您的fork。
请参阅 "Github中的"origin"和"upstream"有什么区别" 了解更多信息。
来源:https://help.github.com/articles/syncing-a-fork/Syncing a fork
Sync a fork of a repository to keep it up-to-date with the upstream repository.
Tip: Before you can sync your fork with an upstream repository, you must configure a remote that points to the upstream repository in Git.
1. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
2. Change the current working directory to your local project.
3. Fetch the branches and their respective commits from the upstream repository. Commits to
master
will be stored in a local branch,upstream/master
.$ git fetch upstream
4. Check out your fork's localmaster
branch.$ git checkout master
5. Merge the changes fromupstream/master
into your localmaster
branch. This brings your fork'smaster
branch into sync with the upstream repository, without losing your local changes.$ git merge upstream/master
If your local branch didn't have any unique commits, Git will instead perform a "fast-forward":
$ git merge upstream/master
Tip: Syncing your fork only updates your local copy of the repository. To update your fork on GitHub, you must push your changes.
Last login: Fri Sep 2 08:45:34 on ttys000
Dos-MacBook-Pro:~ donhuvy$
Dos-MacBook-Pro:~ donhuvy$
Dos-MacBook-Pro:~ donhuvy$ ls
AndroidStudioProjects IdeaProjects Public
Applications Library PycharmProjects
Desktop Movies example.dump
Documents Music pgadmin.log
Downloads Pictures sun-appserv-samples
Dos-MacBook-Pro:~ donhuvy$ cd Documents/
Dos-MacBook-Pro:Documents donhuvy$ ls
$RECYCLE.BIN
13256069_130212657393823_216708148326317354_n.jpg
1511456_1453604554870601_599093550_n.jpg
4578-rc007-jquery_online.pdf
Apps
Programming ebooks
Setup
Treasure_Island_NT.pdf
Video tutorial
Virtual Machines.localized
films
postgresql-9.0-A4.pdf
program_files
source_code
vy.sql
workspace_javaee
Dos-MacBook-Pro:Documents donhuvy$ cd source_code/
Dos-MacBook-Pro:source_code donhuvy$ ls
github.com
Dos-MacBook-Pro:source_code donhuvy$ cd github.com/
Dos-MacBook-Pro:github.com donhuvy$ ls
AurelioDeRosa donhuvy hibernate-orm scrapy spring-projects
Dos-MacBook-Pro:github.com donhuvy$ cd donhuvy/
Dos-MacBook-Pro:donhuvy donhuvy$ ls
ZohoCRM_integration jquery3_examples
java_examples real_estate
Dos-MacBook-Pro:donhuvy donhuvy$ git clone https://github.com/donhuvy/scrapy.git
Cloning into 'scrapy'...
remote: Counting objects: 40481, done.
remote: Total 40481 (delta 0), reused 0 (delta 0), pack-reused 40481
Receiving objects: 100% (40481/40481), 13.98 MiB | 746.00 KiB/s, done.
Resolving deltas: 100% (21135/21135), done.
Checking connectivity... done.
Dos-MacBook-Pro:donhuvy donhuvy$ '
>
>
>
Dos-MacBook-Pro:donhuvy donhuvy$
Dos-MacBook-Pro:donhuvy donhuvy$
Dos-MacBook-Pro:donhuvy donhuvy$ ls
ZohoCRM_integration jquery3_examples scrapy
java_examples real_estate
Dos-MacBook-Pro:donhuvy donhuvy$ cd sc
-bash: cd: sc: No such file or directory
Dos-MacBook-Pro:donhuvy donhuvy$ cd scrapy/
Dos-MacBook-Pro:scrapy donhuvy$ ls
AUTHORS README.rst requirements.txt
CODE_OF_CONDUCT.md artwork scrapy
CONTRIBUTING.md conftest.py sep
INSTALL debian setup.cfg
LICENSE docs setup.py
MANIFEST.in extras tests
Makefile.buildbot pytest.ini tox.ini
NEWS requirements-py3.txt
Dos-MacBook-Pro:scrapy donhuvy$ git log
commit ab42e2b5d531cbbf2ee46b49726604c90becbd3d
Author: vydn <v@vyhn.net>
Date: Sat Apr 2 06:08:28 2016 +0700
Change the content
Change the content
commit bf7f67549378269c3976afc89abcf9c2190d242f
Merge: 9d8c368 9250a5b
Author: Paul Tremberth <paul.tremberth@gmail.com>
Date: Fri Apr 1 15:47:06 2016 +0200
Merge pull request #1847 from aron-bordin/add_blocking_storage_path_setting
[MRG+2] added BLOCKING_FEED_STORAGE_PATH to settings
commit 9250a5bffa91c24dbea5c5d64c3c7cd9992a6ee7
Author: Aron Bordin <aron.bordin@gmail.com>
Date: Sat Mar 5 19:36:02 2016 -0300
added FEED_TEMPDIR to settings
commit 9d8c368ce8a24d7adb63b731df1359f3b05f3bdd
Dos-MacBook-Pro:scrapy donhuvy$
Dos-MacBook-Pro:scrapy donhuvy$
Dos-MacBook-Pro:scrapy donhuvy$ git fetch upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Dos-MacBook-Pro:scrapy donhuvy$ git remote -v
origin https://github.com/donhuvy/scrapy.git (fetch)
origin https://github.com/donhuvy/scrapy.git (push)
Dos-MacBook-Pro:scrapy donhuvy$ git remote add upstream https://github.com/scrapy/scrapy.git
Dos-MacBook-Pro:scrapy donhuvy$ git remote -v
origin https://github.com/donhuvy/scrapy.git (fetch)
origin https://github.com/donhuvy/scrapy.git (push)
upstream https://github.com/scrapy/scrapy.git (fetch)
upstream https://github.com/scrapy/scrapy.git (push)
Dos-MacBook-Pro:scrapy donhuvy$ git fetch upstream
remote: Counting objects: 1329, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 1329 (delta 600), reused 599 (delta 599), pack-reused 723
Receiving objects: 100% (1329/1329), 425.28 KiB | 325.00 KiB/s, done.
Resolving deltas: 100% (920/920), completed with 141 local objects.
From https://github.com/scrapy/scrapy
* [new branch] 0.12 -> upstream/0.12
* [new branch] 0.14 -> upstream/0.14
* [new branch] 0.16 -> upstream/0.16
* [new branch] 0.18 -> upstream/0.18
* [new branch] 0.20 -> upstream/0.20
* [new branch] 0.22 -> upstream/0.22
* [new branch] 0.24 -> upstream/0.24
* [new branch] 1.0 -> upstream/1.0
* [new branch] 1.1 -> upstream/1.1
* [new branch] asyncio -> upstream/asyncio
* [new branch] deprecate-make-requests-from-url -> upstream/deprecate-make-requests-from-url
* [new branch] disable-toplevel-2 -> upstream/disable-toplevel-2
* [new branch] doc-arch-overview2 -> upstream/doc-arch-overview2
* [new branch] feature-1371-download-prios -> upstream/feature-1371-download-prios
* [new branch] fix-1330 -> upstream/fix-1330
* [new branch] fix-util-function-to-work-outside-project-dir -> upstream/fix-util-function-to-work-outside-project-dir
* [new branch] link-encoding -> upstream/link-encoding
* [new branch] master -> upstream/master
* [new branch] no-max-rss -> upstream/no-max-rss
* [new branch] py3-chunked -> upstream/py3-chunked
* [new branch] release-notes-1.1.2-master -> upstream/release-notes-1.1.2-master
* [new branch] remove-prerelease-configuration -> upstream/remove-prerelease-configuration
* [new tag] 1.0.6 -> 1.0.6
* [new tag] 1.1.2 -> 1.1.2
* [new tag] 1.1.0 -> 1.1.0
* [new tag] 1.1.0rc4 -> 1.1.0rc4
* [new tag] 1.1.1 -> 1.1.1
Dos-MacBook-Pro:scrapy donhuvy$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Dos-MacBook-Pro:scrapy donhuvy$ git merge upstream/master
error: There was a problem with the editor 'vi'.
Not committing merge; use 'git commit' to complete the merge.
Dos-MacBook-Pro:scrapy donhuvy$ git commit -m "update"
[master 6f16b46] update
Dos-MacBook-Pro:scrapy donhuvy$ git push
Counting objects: 915, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (380/380), done.
Writing objects: 100% (915/915), 235.84 KiB | 0 bytes/s, done.
Total 915 (delta 677), reused 769 (delta 535)
remote: Resolving deltas: 100% (677/677), completed with 99 local objects.
To https://github.com/donhuvy/scrapy.git
ab42e2b..6f16b46 master -> master
Dos-MacBook-Pro:scrapy donhuvy$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Dos-MacBook-Pro:scrapy donhuvy$
重要提示:
步骤1。 切换目录:
cd /Users/donhuvy/Documents/source_code/github.com/donhuvy/
确保操作无误:
pwd
步骤2. 前往https://github.com/donhuvy/scrapy,查看页面右上方,复制存储库链接。
https://github.com/donhuvy/scrapy.git
步骤 3. 从服务器克隆到本地
git clone https://github.com/donhuvy/scrapy.git
第四步。 前往 https://github.com/scrapy/scrapy,查看右上角,复制存储库链接。
https://github.com/scrapy/scrapy.git
步骤 5. 添加上游仓库链接
git remote add upstream https://github.com/scrapy/scrapy.git
步骤6. 检查仓库列表: git remote -v
结果:
origin https://github.com/donhuvy/scrapy.git (获取) origin https://github.com/donhuvy/scrapy.git (推送) upstream https://github.com/scrapy/scrapy.git (获取) upstream https://github.com/scrapy/scrapy.git (推送)
步骤7. 获取上游代码
git fetch upstream
步骤8. 从上游仓库获取主分支
git checkout master
步骤9. 合并源代码:
git merge upstream/master
在终端中打开Vim编辑器,然后您可以编辑提交消息。按i键开始编辑,按esc键,输入:wq!保存并退出。
步骤10. 进行提交。
git commit -m "update"
步骤11。 推送 git push
步骤12。 确认无误
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Of course, I try to my post have no 13rd step.
Reference:
https://help.github.com/articles/configuring-a-remote-for-a-fork/ https://help.github.com/articles/syncing-a-fork/