Git 如何从远程服务器成功更新本地存储库?

Git 如何从远程服务器成功更新本地存储库?,git,github,git-merge,git-rebase,Git,Github,Git Merge,Git Rebase,在github.org中,B有一个名为helloworld.git的存储库和两个分支 http://github.org/B/helloworld.git: master dev --> always updated. 我将存储库分支到我的帐户A,并创建了一个名为test的新分支 http://githu.org/A/helloworld.git: master dev test --&

github.org
中,
B
有一个名为
helloworld.git
的存储库和两个分支

    http://github.org/B/helloworld.git:
        master
        dev   --> always updated.
我将存储库分支到我的帐户
A
,并创建了一个名为
test
的新分支

    http://githu.org/A/helloworld.git:
        master
        dev
        test  --> do my work and commit it into this branch
我已将存储库签出到我的本地计算机:

    git clone http://github.org/A/helloworld.git
    git checkout master
    git checkout dev
    git checkout test
然后,我想从
B
的存储库中更新我的本地存储库:

    git remote add upstream http://github.org/B/helloworld.git
    git fetch upstream
    git checkout master
    git merge upstream/master
    git checkout dev
    git merge upstream/dev
而且,如果我使用
git status
,它会说
您的分支比“origin/dev”领先22次提交。

但是,当我进行提交时,出现了一个错误:

    git checkout test
    (do some modifications in doc/Readme.md)
    git add doc/Readme.md
    git commit -am "modified doc/Readme.md"
    git push origin test
有一个错误:

    fatal: Authentication failed

怎么了?我怎样才能成功地完成这项工作?谢谢

如果您使用https url进行原始回购,引用您的fork,则需要输入您的
A
GitHub帐户登录/密码作为凭证

使用git remote-v检查您当前的遥控器

我更喜欢在url中添加用户名,以便只输入密码:

git remote set-url origin http://A@github.org/A/helloworld.git

答案是将
SSH
密钥添加到
github
:生成
id\u dsa.pub
,然后将其内容复制到
github
帐户,然后
git远程设置url源git@github.com:A/helloworld.git
,然后
git推送原点测试
。它起作用了!