1

As illustrated by the commands below, a git clone has successfully been used as a git repository and has had changes pushed to it. But then, git status does not detect any difference between the updated clone and the original git repository -- why?

$ mkdir -p /var/tmp/git_master
$ cd /var/tmp/git_master
$ git clone https://the_repo.com/stuff.git

Cloning into 'stuff'...

~
~
~

$ cd
$ mkdir fooey
$ cd fooey
$ git clone /var/tmp/git_master/stuff

Cloning into 'stuff'...
done.

$ cd stuff/
$ git branch test
$ git checkout test

Switched to branch 'test'

$ touch test.txt

~
~
~
$ git commit -m"initial"
$ git push origin test

Counting objects: 6, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 526 bytes | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
To /var/tmp/git_master/stuff
 * [new branch]      test -> test

$ pushd /var/tmp/git_master/stuff
$ git branch
* master
  test
$ git status

On branch master

Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean

$

Why doesn't git status report that /var/tmp/git_master/stuff contains a local branch named test that is not in the remote repository https://the_repo.com/stuff.git?

Output from accepted answer git branch -avv

$ git branch -avv
* master                52a921c [origin/master] some message
  test                  39dbcbf some message
  remotes/origin/HEAD   -> origin/master
  remotes/origin/xyz    b5edac5 some message
  remotes/origin/master 52a921c some message

Leads to another question: how to push all changes in /var/tmp/git_master/stuff to the remote repository https://the_repo.com/stuff.git? (I trust this follow-up question need not be asked separately since it completes the issue being tackled by the original question.)

Resolution to follow-up question can be found here https://stackoverflow.com/a/6232535/1823664 -- git checkout test followed by git push -u. There is also this suggestion that a few have derided: https://stackoverflow.com/a/21232996/1823664

user1823664
  • 1,071
  • 9
  • 16
  • 1
    git status only reports changes to files, staged or untracked files. To see branch details, you need to use git branch -avv like VonC has answered. – nj2237 Aug 02 '17 at 05:08

1 Answers1

2

Why doesn't git status report that /var/tmp/git_master/stuff contains a local branch named test that is not in the remote repository https://the_repo.com/stuff.git?

To see exactly that, type:

git branch -avv

You will see that test is not linked to any remote tracking branch.
As opposed to master, linked to origin/master.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250