Issue
This Content is from Stack Overflow. Question asked by B-zaro
git shows that all desired directories/files have been successfully committed to my local master branch via:
git ls-tree -r --name-only master
This command git push -u $destination_git_branch $source_git_branch
informs me that Everything up-to-date
Problem:
None of my files are actually being written to the destination repo.
Therefore, I double-checked that my git hook post-receive
was executable and had the correct directory information:
git --work-tree=/home/username/public_html --git-dir=/home/username/public_html/git/production.git checkout -f
Sure this is a rookie error, but why aren’t my files actually being push the correct location?
Solution
MIND BOGGLING SOLUTION:
Being a git rookie, I suspected that maybe I had done something wrong within my .gitignore
file. Therefore, I mv .gitignore .gitignore.bak
and created a fresh .gitignore
BAM!!! everything worked.
At this point I ran a diff .gitignore .gitignore.bak
command to see what the bad setting was…. There wasn’t a bad setting:
$ diff .gitignore .gitignore.bak
26,27c26,27
< /push-staging.sh
< /pull-staging.sh
---
> /push.sh
> /pull.sh
30c30
< /.gitignore.bak
---
> /test-push-db-import.sh
34c34
< /test-push-db-import.sh
---
>
40a41
> #/wp-content/themes/generatepress*/
The PROBLEM seems to be that the .gitignore
somehow had incorrect permissions:
$ stat .gitignore.bak
File: .gitignore.bak
Size: 1210 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 810573 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1037/username) Gid: ( 1036/username)
Access: 2022-09-19 11:10:00.960804347 +0800
Modify: 2022-09-19 10:32:54.604206792 +0800
Change: 2022-09-19 10:33:16.186992558 +0800
Birth: -
$ stat .gitignore
File: .gitignore
Size: 1205 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 800408 Links: 1
Access: (0660/-rw-rw----) Uid: ( 1037/username) Gid: ( 1036/username)
Access: 2022-09-19 11:10:00.960804347 +0800
Modify: 2022-09-19 10:57:27.408224628 +0800
Change: 2022-09-19 10:57:27.408224628 +0800
Birth: -
This Question was asked in StackOverflow by B-zaro and Answered by B-zaro It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.