0

I have a bare repository set up in my remote ubuntu server. I can access it from both local repository and remote repository, including another repository in the same Ubuntu server with working area. The name of the repository is warehouse with only 1 branch named as "main" and as HEAD. The "master" branch has been deleted due to some unresolvable conflicts. I changed the name "master" to "main" in all repositories.

"git push" and "git pull" works perfectly. But after a new commision is pushed to the repository, "git status" shows "up to date" from all terminals. I expect I see updates from the bare repository. Anyway, "git pull" gets all updates correctly, and "git remote show xxx" shows "out of date" correctly. Why "git status" shows "up to date"?

local bash> git status
On branch main
Your branch is up to date with 'warehouse/main'. 

local bash> git remote show warehouse
* remote warehouse
  Fetch URL: xxx@xxxx.xxx:/path/to/git/
  Push  URL: xxx@xxxx.xxx:/path/to/git/
  HEAD branch: main
  Remote branch:
    main tracked
  Local branch configured for 'git pull':
    main merges with remote main
  Local ref configured for 'git push':
    main pushes to main (up to date)
letrois
  • 13
  • 2

1 Answers1

2

Git does not do anything automatically. A Git repo does not automatically "know" what's happening on a corresponding remote. It doesn't look at the corresponding remote until you give it a command that tells it to communicate with the remote.

git push is such a command. git pull is such a command. git remote show is such a command. But git status is not.

If you want a local Git to update its knowledge of what's going on at the corresponding remote, say git fetch.

torek
  • 448,244
  • 59
  • 642
  • 775
matt
  • 515,959
  • 87
  • 875
  • 1,141