【问题标题】:How to synchronise the git repository using git hub?如何使用 github 同步 git 存储库?
【发布时间】:2015-12-21 09:55:28
【问题描述】:

我最近开始使用 git。所以,这就是我所做的——在 git hub 中创建一个 git 存储库。我有一个项目,所以我通过以下命令将我的项目推送到了 github -

机器 1 (Ubuntu) - 地点 1

git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/joshis1/XPlatformCoreDumpAnalyzer.git
git push -u origin master

机器 2(OSX) 地点 2

接下来,我在另一台机器和网络中检查了这段代码 - 使用 git clone。

接下来,我在 MACHINE 2,PLACE 2 上做了

我创建了一个分支 GUI_COMPRESSION_OPTION_FIX,我可以在 github 中看到这个分支 - https://github.com/joshis1/XPlatformCoreDumpAnalyzer/branches


问题 - 机器 1 地点 1

当我做一个

git pull  https://github.com/joshis1/XPlatformCoreDumpAnalyzer.git

另外,当我执行 gitk 时,它不会显示分支名称 - GUI_COMPRESSION_OPTION_FIX。

看起来,我的本地 git 存储库没有同步。我的问题是如何强制重新同步以便我看到新的分支名称。我也试过变基。

【问题讨论】:

    标签: git github version-control


    【解决方案1】:

    你有它(或者至少我在克隆你的仓库时得到了它):

    git clone https://github.com/joshis1/XPlatformCoreDumpAnalyzer.git
    Cloning into 'XPlatformCoreDumpAnalyzer'...
    remote: Counting objects: 18, done.
    remote: Compressing objects: 100% (12/12), done.
    remote: Total 18 (delta 5), reused 18 (delta 5), pack-reused 0
    Unpacking objects: 100% (18/18), done.
    Checking connectivity... done.
    

    只需执行“git branch --all”,您就会在那里找到远程跟踪分支。当您获取/拉取时,您会自动在本地仓库中获取远程分支:

    ~/test/XPlatformCoreDumpAnalyzer (master)$ git branch --all
    * master
      remotes/origin/GUI_COMPRESSION_OPTION_FIX
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
    

    “git branch -avv”也显示了本地分支到远程跟踪分支的映射:

    git branch -avv
    * master                                    3bd3020 [origin/master] Initial Version - Created the GUI framework for the coredump utility.
      remotes/origin/GUI_COMPRESSION_OPTION_FIX 92465c1 Fixed GUI - compression Type Fix and Logo Fix attempt.
      remotes/origin/HEAD                       -> origin/master
      remotes/origin/master                     3bd3020 Initial Version - Created the GUI framework for the coredump utility.
    

    签出远程跟踪分支以创建本地分支git checkout GUI_COMPRESSION_OPTION_FIX(链接到远程跟踪分支),现在您也会将其视为本地分支:

    git branch -avv
    * GUI_COMPRESSION_OPTION_FIX                92465c1 [origin/GUI_COMPRESSION_OPTION_FIX] Fixed GUI - compression Type Fix and Logo Fix attempt.
      master                                    3bd3020 [origin/master] Initial Version - Created the GUI framework for the coredump utility.
      remotes/origin/GUI_COMPRESSION_OPTION_FIX 92465c1 Fixed GUI - compression Type Fix and Logo Fix attempt.
      remotes/origin/HEAD                       -> origin/master
      remotes/origin/master                     3bd3020 Initial Version - Created the GUI framework for the coredump utility.
    

    【讨论】:

    • 是的,当我使用克隆进行全新结帐时,它可以工作。但是,当我在现有沙箱上同步时,它不起作用。我做了 git checkout remotes/origin/GUI_COMPRESSION_OPTION_FIX
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 2014-08-18
    • 2011-07-19
    • 2018-05-16
    • 2021-03-05
    • 1970-01-01
    相关资源
    最近更新 更多