I am currently using the Windows Github GUI and its pretty cool looking and easy so I'm trying to use it as often. A problem I encountered is when I fork a project I don't know how to update that fork with the git
4 回答
仅供参考,我在此处复制http://processwire.com/talk/topic/1565-github-for-windows/上的帖子中的详细说明:
- 在“GitHub for Windows”本地存储库视图中,右键单击并选择“
open a shell here
” - 这将打开一个已经在正确目录中的 shell。键入以下命令:
# 将原始 repo 分配给名为“upstream”的远程 git 远程添加上游 https://github.com/path_to_your_repository.git # 从原始存储库中提取本地存储库中不存在的更改, # 不修改你的文件。 # 允许您先查看。 git 获取上游 # 将获取的更改合并到您的工作文件中。 git 合并上游/主
GitHub for Windows 目前仅支持一个遥控器(origin
引用您的 fork)。
因此,您需要手动添加一个upstream
引用原始存储库的远程(称为“”),以便您能够(从 CLI)从中提取upstream
、更新本地存储库并允许您推送(这次使用 GUI)新的提交到你的 fork。
有关更多信息,请参阅“ github 中的 origin 和 upstream 有什么区别”。
同步分叉
同步存储库的分支以使其与上游存储库保持同步。
提示:在您可以将您的分叉与上游存储库同步之前,您必须在 Git 中配置一个指向上游存储库的远程。
1.打开终端(Mac 用户)或命令提示符(Windows 和 Linux 用户)。
2.将当前工作目录更改为您的本地项目。
3.从上游存储库中获取分支及其各自的提交。提交的
master
内容将存储在本地分支中,upstream/master
.$ git fetch upstream
4.检查你的 fork 的本地master
分支。$ git checkout master
5.将更改合并upstream/master
到您的本地master
分支中。这将使您的 forkmaster
分支与上游存储库同步,而不会丢失您的本地更改。$ git merge upstream/master
如果您的本地分支没有任何唯一的提交,Git 将改为执行“快进”:
$ git merge upstream/master
提示:同步您的 fork 只会更新您的本地存储库副本。要在 GitHub 上更新您的分叉,您必须推送您的更改。
来源: https ://help.github.com/articles/syncing-a-fork/
在 Windows 版 Github(GUI 应用程序)中,按 按钮Sync
,然后应用程序会将更改的文件上传到您自己的存储库(在 Github.com)。
如何从原始存储库同步分叉存储库?
为了便于理解,我称之为一个现实的例子:同步这个存储库:https ://github.com/donhuvy/scrapy from https://github.com/scrapy/scrapy
有所有步骤:
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
Step 2.去https://github.com/donhuvy/scrapy看右上角,复制仓库链接
https://github.com/donhuvy/scrapy.git
步骤 3.从服务器克隆到本地
git clone https://github.com/donhuvy/scrapy.git
Step 4.去https://github.com/scrapy/scrapy,看右上角,复制仓库链接
https://github.com/scrapy/scrapy.git
步骤 5.添加上游存储库链接
git remote add upstream https://github.com/scrapy/scrapy.git
步骤 6.检查 repo 列表:git remote -v
结果:
来源 https://github.com/donhuvy/scrapy.git (fetch) 来源 https://github.com/donhuvy/scrapy.git (push) 上游 https://github.com/scrapy/scrapy.git (fetch ) 上游 https://github.com/scrapy/scrapy.git (推送)
步骤 7.获取上游
git fetch upstream
步骤 8.从上游仓库获取 master 分支
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.
参考:
https://help.github.com/articles/configuring-a-remote-for-a-fork/ https://help.github.com/articles/syncing-a-fork/