Git pull from my public repository not working

旧城冷巷雨未停 提交于 2019-12-24 18:18:51

问题


This is my .git/config configuration file in my repository:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:<username>/<repository>.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[user]
    name = <username>

I have correctly configured my public ssh key in github. I pushed my changes into this repository from another machine, which where correctly updated into github.

However in my current machine, when I make a git pull request:

git pull origin master

It says "already up to date"

When it's not the case at all, the updated files in my github repository are not in my local repository.

What can I be doing wrong?

UPDATE:

I've tried the following from the answer from Olivier Refalo:

In github and in local the branches are master.

The output to the command:

git for-each-ref --format="local: %(refname:short) <--sync--> remote: %(upstream:short)" refs/heads

Is the following:

local: master <--sync--> remote:

git remove -v returns the following output:

origin git@github.com:username/repository.git (fetch)

origin git@github.com:username/repository.git (push)


回答1:


Multiple things can happen here:

I would trust git, the remote is in sync with your local. The problem here is that it may be pointed to a different location than want you think.

  1. you may be pushing local branch XYZ (not master) to origin/master
  2. you may be pushing to a different URL

to figure this out, run the following code:

  1. git branch, make sure you are on master
  2. git for-each-ref --format="local: %(refname:short) <--sync--> remote: %(upstream:short)" refs/heads
  3. git remote -v

The later will show an association table showing which local branch syncs with which remote. Finally the latest statement shows your remote urls.

I took these commands from a project of mine G2




回答2:


I didn't find out what was the problem so what I did was a new git clone from github in order to get the updated files.




回答3:


try ot use force pull. add "force" between git and pull



来源:https://stackoverflow.com/questions/12086897/git-pull-from-my-public-repository-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!