Why is Git falsely noting that my files are up-to-date?
git pull
's job is to fetch
new commits and merge
them into the current branch. If the current branch is not outdated compared to the one you pull from, pull will say Already up-to-date.
even if you have local changes in your working directory. git pull
is concerned with branches, not the working tree — it will comment on the working tree only if there are changes which interfere with the merge.
Your description is insufficient to explain why it's not objecting to the existing index.html
, but you should not take Already up-to-date.
as meaning git thinks you have no changes. Instead, use git status
to obtain a summary.
In order to understand the state of your branches, git branch -v
is useful (it shows the commit ID and relation to each branch's upstream branch), or gitk --all
for a graphical view of all commits.
If I understand correctly the following script should reproduce your issue:
mkdir test cd test git init --bare test.git git clone test.git a git clone test.git b echo a > a/index.html echo b > b/index.html cd b git add index.html git commit -m add git push origin master cd ../a git pull
The last git pull
prints:
remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From /home/cyrus/tmp/test/test * [new branch] master -> origin/master
And the content of index.html
has been silently overwritten:
cyrus:~/tmp/test/a$ cat index.html b