简体   繁体   中英

Git Not Pushing Committed Files

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 

update:
This verifies that the correct repo is targeted by the local git push command:

$ git remote -v
$destination_git_branch ssh_user@123.456.789.12:public_html/git/staging.git (fetch)
$destination_git_branch ssh_user@123.456.789.12:public_html/git/staging.git (push)

Note: the --git-dir= was incorrect and set for production rather than staging . Therefore, I re-initialized the destination repo with git init --bare and on the local test server I removed, then re-added the remote/destination repo.

Same problem.

The issue seems to be that post-receive isn't being executed. Within post-receive I do have #!/bin/sh and I added exec 5>> /home/adminbvcs/logs/post-receive.log; BASH_XTRACEFD="5"; PS4='$LINENO: '; set -x; exec 5>> /home/adminbvcs/logs/post-receive.log; BASH_XTRACEFD="5"; PS4='$LINENO: '; set -x; in another window I have tail -f /home/username/logs/post-receive.log

Nothing enters the log when I push.

The post-receive is executable:

~/public_html/git/staging.git/hooks$ stat post-receive
  File: post-receive
  Size: 320         Blocks: 8          IO Block: 4096   regular file
Device: fd04h/64772d    Inode: 2228925     Links: 1
Access: (0751/-rwxr-x--x)  Uid: ( 1059/username)   Gid: ( 1036/username)
Access: 2022-09-19 10:03:39.267891777 +0800
Modify: 2022-09-19 10:02:43.366922815 +0800
Change: 2022-09-19 10:18:55.287857468 +0800
 Birth: -

Sure this is a rookie error, but why aren't my files actually being push the correct location?

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: -

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM