更改存在于被跟踪的分支的上游,但是当我输入git status时,它表明我的本地分支是最新的。这是新的行为,我改变了配置设置,还是有什么错误?

ubuntu@host:/my/repo# git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean


ubuntu@host:/my/repo# git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 11 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.
From bitbucket.org:my/repo
   1234567..abcdefg  master     -> origin/master
Updating 1234567..abcdefg
Fast-forward
 file1        |  1 -
 file2        | 43 +++++++++++++++++++++++++++++++++++++++++++
 file3        | 21 ++++++++++++---------
 file4        | 21 ++++++++++++---------
 4 files changed, 67 insertions(+), 19 deletions(-)
 create mode 100644 file5

当前回答

导致我这个错误的原因是在错误的文件夹中做git状态…检查这个。

其他回答

让我们查看一个示例git repo,以验证您的分支(master)是否与origin/master保持一致。

验证本地主服务器正在跟踪原点/主服务器:

$ git branch -vv
* master a357df1eb [origin/master] This is a commit message

更多关于本地主分支的信息:

$ git show --summary
commit a357df1eb941beb5cac3601153f063dae7faf5a8 (HEAD -> master, tag: 2.8.0, origin/master, origin/HEAD)
Author: ...
Date:   Tue Dec 11 14:25:52 2018 +0100

    Another commit message

验证origin/master是否在同一个提交上:

$ cat .git/packed-refs | grep origin/master
a357df1eb941beb5cac3601153f063dae7faf5a8 refs/remotes/origin/master

我们可以看到相同的散列,并且可以肯定地说分支与远程分支是一致的,至少在当前的git repo中是这样。

在这种情况下,使用git添加和集成所有挂起的文件,然后使用git commit和git push

Git添加-集成所有暂存文件

Git提交-保存提交

Git推送- 保存到存储库

这个答案微不足道,但在某些情况下是准确的,比如让我来到这里的那个问题。 我在一个回购工作,这对我来说是新的,我添加了一个文件,这不是新的状态。

最终该文件与.gitignore文件中的模式匹配。

导致我这个错误的原因是在错误的文件夹中做git状态…检查这个。

我也遇到过类似的问题,我在网上到处搜索解决方案,并试图遵循它们。没有一个对我有效。这些是我针对这个问题采取的步骤。

创建新的repo并将现有代码再次推到新的repo

如果您的存储库中已经有. Git /文件夹,则Git init不会初始化。所以,就你的情况来说,做

(1) rm -rf .git/

2)滚英寸

(3) git远程添加origin https://repository.remote.url

(4) git commit -m“提交信息”

(5) git push -f origin master

请注意,所有git配置,如该存储库的远程存储库,都将在步骤1中清除。因此,您必须重新设置所有远程存储库url。

另外,注意第5步中的-f:远程已经有n次提交的一些代码库,您试图将所有这些更改都提交到一次提交中。因此,强制将更改推到远程是必要的。