Please look at this example:
pi@rpi2:~/git/test $ mkdir remote_rep
pi@rpi2:~/git/test $ cd remote_rep/
pi@rpi2:~/git/test/remote_rep $ git init
Initialized empty Git repository in /home/pi/git/test/remote_rep/.git/
pi@rpi2:~/git/test/remote_rep $ touch readme.txt
pi@rpi2:~/git/test/remote_rep $ git add readme.txt
pi@rpi2:~/git/test/remote_rep $ git commit -m "initial commit"
[master (root-commit) 4dd0ba4] initial commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 readme.txt
pi@rpi2:~/git/test/remote_rep $ git status
On branch master
nothing to commit, working tree clean
pi@rpi2:~/git/test/remote_rep $ git log
commit 4dd0ba4797989d39dd7bb42da8de58dfac3ebad8
Author: pi <pi@abc.com>
Date: Mon Sep 21 20:13:19 2020 +0000
initial commit
pi@rpi2:~/git/test/remote_rep $ cd ..
pi@rpi2:~/git/test $ mkdir local
pi@rpi2:~/git/test $ cd local/
pi@rpi2:~/git/test/local $ git clone ~/git/test/remote_rep/
Cloning into 'remote_rep'...
done.
pi@rpi2:~/git/test/local $ ls
remote_rep
pi@rpi2:~/git/test/local $ cd remote_rep/
pi@rpi2:~/git/test/local/remote_rep $ ls
readme.txt
pi@rpi2:~/git/test/local/remote_rep $ cat readme.txt
pi@rpi2:~/git/test/local/remote_rep $ echo "abc" > readme.txt
pi@rpi2:~/git/test/local/remote_rep $ cat readme.txt
abc
pi@rpi2:~/git/test/local/remote_rep $ git commit -m "updated readme.txt"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: readme.txt
no changes added to commit
pi@rpi2:~/git/test/local/remote_rep $ git push
Everything up-to-date
pi@rpi2:~/git/test/local/remote_rep $ git remote show
origin
pi@rpi2:~/git/test/local/remote_rep $ git remote -v
origin /home/pi/git/test/remote_rep/ (fetch)
origin /home/pi/git/test/remote_rep/ (push)
pi@rpi2:~/git/test/local/remote_rep $
How come that by issuing:
pi@rpi2:~/git/test/local/remote_rep $ git push
Everything up-to-date
I got a message "Everything up-to-date", but as you can see readme.txt has been changed.
If I continue with:
pi@rpi2:~/git/test/local/remote_rep $ git add readme.txt
pi@rpi2:~/git/test/local/remote_rep $ git commit -m "updated abc"
[master 136cdba] updated abc
1 file changed, 1 insertion(+)
pi@rpi2:~/git/test/local/remote_rep $ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 241 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set 'receive.denyCurrentBranch' configuration variable to
remote: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/pi/git/test/remote_rep/
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/home/pi/git/test/remote_rep/'
pi@rpi2:~/git/test/local/remote_rep $
What am I missing? git version 2.11.0
I cannot submit this question due to stackoverflow error: "It looks like your post is mostly code; please add some more details.", so I am adding here this text just to change discrepancy. Please ignore this last paragraph.