【问题标题】:Pulling Github repo back拉回 Github 回购
【发布时间】:2013-06-12 11:51:03
【问题描述】:

我在 github 创建了一个 git repo 并在家里克隆了它:

 - eris:utility-functions$ ls
README

 - eris:utility-functions$ git status
# On branch master
nothing to commit, working directory clean

 - eris:utility-functions$ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/dotancohen/utility-functions.git
        fetch = +refs/heads/*:refs/remotes/origin/*

 - eris:utility-functions$ git log --pretty=oneline
d444d752ed18b9d5b8422621b841413c30159d3c first commit

在工作中我已经克隆了 repo,做了一些提交,然后推送回了 github:

 - bruno:utility-functions$ ls
example-usage.php  README.md  solr.php  util.php

 - bruno:utility-functions$ git status
# On branch master
nothing to commit (working directory clean)

 - bruno:utility-functions$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://github.com/dotancohen/utility-functions.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

 - bruno:utility-functions$ git log --pretty=oneline
cbfe00402226457aed50f658126783151b074759 get_user_ip_address(): Handle multiple addresses for all types
998d57e333d0a0700539f7c6c12b9bad5536b430 get_user_ip_address(): Handle multiple addresses
6ed9d43a05ab8f0a4191da84d8025db59095f8c3 Add function for sending mail with Amazon Simple Email Service
051c8e3f4982028cef677b486b305f3057be1be4 Added get_external_ip_address() which relies on simplesniff.com.
76e574f9260cae0f9fc00ed56b9b6da5f3f37c42 Provide example usage for ensure_fields() function.
39a6471627e1be6b0351257428e634c6f45dd234 ensure_fields(): Properly document ensure_fields(): Return NULL on invalid i
c0b06fb40b86cba67edafc1454df64e4e8e9c9a2 Merge branch 'master' of https://github.com/dotancohen/utility-functions
1aa18cbdef9643f3d964a97ccda41df414e009cf Added ensure_fields() function. Added example usage page.
63840793056ce75ac0e9b7dcbcd9683980a24a2c Added ensure_fields() function. Added example usage page.
5cf5aba1fd808433570c7e4c2693acf03a0de862 Initial solr.php file. Added solr_escape() function.
5e75c0499bc4b1fe1350577726b0566d7c647a8e Initial commit

 - bruno:utility-functions$ git push
WARNING: gnome-keyring:: couldn't connect to: /run/user/dotancohen/keyring-wHsyrf/pkcs11: No such file or directory
Username for 'https://github.com': dotancohen
Password for 'https://dotancohen@github.com': 
Everything up-to-date

现在当我尝试在家里拉时,我对分支感到困惑:

 - eris:utility-functions$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

我对简单地做git branch --set-upstream-to=origin/master master 持谨慎态度,因为我不确定我当前的提交会发生什么。 由于我从未更改家用 (eris) 计算机上的分支,因此可能导致错误的原因是什么?在家运行命令git branch --set-upstream-to=origin/master master 安全吗?为什么我不必从工作计算机 (bruno) 执行此操作?

谢谢!

【问题讨论】:

    标签: github


    【解决方案1】:

    git branch --set-upstream-to=origin/master master 因为我不确定我当前的提交会发生什么。

    您当前在 master 上的提交不会发生任何事情。

    然后,git pull 将获取 origin/master 并将其合并到 master。

    如果您愿意,可以先git fetch,然后再examine the diff between the two branches before merging
    Mark Longair的帖子“git: fetch and merge, don’t pull

    为什么我不必在工作计算机 (bruno) 上执行此操作?

    可能是因为您在第一次下班推送时执行了git push -u origin master,这会将远程跟踪分支设置为(工作)master
    详情请参阅“Why do I need to explicitly push a new branch?”。

    【讨论】:

    • 谢谢,这正是我需要知道的。
    猜你喜欢
    • 2020-04-07
    • 1970-01-01
    • 2013-02-01
    • 2012-05-28
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    • 2021-03-29
    • 1970-01-01
    相关资源
    最近更新 更多