简体   繁体   English

Git推送到远程而不更新文件

[英]Git push to a remote not updating files

I have a git repo set up with two remotes ORIGIN and WEB both are bare. 我有一个git repo设置了两个远程ORIGIN和WEB都裸了。

When pushing to ORIGIN the push completes the log shows the commit and the files are updated. 当推送到ORIGIN时,推送完成,日志显示提交并更新文件。

When pushing to WEB the push completes (a subsequent push says Everything up to date). 当推送到WEB时,推送完成(随后的推送显示“一切都是最新的”)。 The log on the web remote shows the commit occurred successfully but none of the files are modified according to the commit. Web远程服务器上的日志显示提交成功完成,但是没有根据提交修改任何文件。

What could be going wrong please? 请问可能出什么问题了?

EDIT 1 - commands and replies as requested 编辑1-命令和要求的答复

local$  git branch
* master

remote$ git branch
* master


local$ git add newfile
local$ git commit -m "added newfile"

[master 591680a] added newfile
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 public_html/newfile


local$ git push web master

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://user@myhost/home/user
c5b7713..591680a  master -> master


remote$ git log

commit 591680a73fdf535c44031cca545b2a47e8421fac
Author: Matthew Slight <matthew@slight.me>
Date:   Mon Oct 17 06:24:10 2016 +0400

added newfile


remote$ ls newfile

No such file or directory

Thanks, Matthew 谢谢,马修

You might want to try specifying the branches involved, like 您可能想尝试指定涉及的分支,例如

$ git push web HEAD:master

(being master the branch you are pushing to the remote) master要推送到远程的分支)

Make sure you have pulled and are on the right branch on your remote: 确保已拉出并位于遥控器的正确分支上:

git checkout master
git pull
git status

and when doing git log , try git log --decorate instead, which will show the branch references as well. 当执行git log ,请尝试使用git log --decorate代替,它也会显示分支引用。

Actually, it is not recommended to use the remote git repo in that way. 实际上,不建议以这种方式使用远程git repo。 first of all, on the remote pc(server), you should init a bare git repo, using 首先,在远程PC(服务器)上,您应该使用以下命令初始化一个裸git repo

git init --bare git init-裸

and then set the workplace for the repo in any other diretory on you server etc. google the usage of git init --bare 然后在服务器等任何其他目录中为回购设置工作场所。google git init --bare的用法

However, if you did want to work in that way, I think this will help: 但是,如果您确实想以这种方式工作,那么我认为这将有所帮助:

https://git-annex.branchable.com/tips/making_a_remote_repo_update_when_changes_are_pushed_to_it/ https://git-annex.branchable.com/tips/making_a_remote_repo_update_when_changes_are_pushed_to_it/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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