如何推送到非Git仓库? [英] How to push to a non-bare Git repository?

查看:104
本文介绍了如何推送到非Git仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常通过ssh(screen和vim)在远程服务器上工作,我有一个Git存储库。有时我不在线,所以我在我的笔记本电脑上有一个单独的存储库(从我的远程克隆)。



但是,我无法从远程存储库因为我通常在防火墙后面,或者我没有公共IP。



我读过我应该推到一个裸仓库。我应该如何将更改推送到远程存储库?

git / git / blob / v2.3.0 / Documentation / config.txt#L2155> receive.denyCurrentBranch updateInstead ,添加在Git 2.3中,也会更新服务器的工作树。

因此,如果您确保在本地拉出之前始终提交,并在服务器上保留一个干净的工作树(您应该这样做以避免合并冲突),那么此选项是一个很好的解决方案。



示例用法:

  git init服务器
cd服务器
触摸
git add。
git commit -m 0
git config --local receive.denyCurrentBranch updateInstead

cd ..
git克隆服务器本地
cd本地
触摸b
git add。
git commit -m 1
git push origin master:master

cd ../server
ls

输出:

  a 
b


I usually work on a remote server via ssh (screen and vim), where I have a Git repository. Sometimes I'm not online, so I have a separate repository (cloned from my remote) on my laptop.

However, I can't pull from this repository on remote side because I'm usually behind a firewall or I don't have a public IP.

I've read that I should push just to a bare repository. How should I then push my changes to my remote repository?

解决方案

receive.denyCurrentBranch updateInstead, added in Git 2.3, also updates the server's working tree if it is clean.

So if you ensure that you always commit before you pull locally, and keep a clean working tree on the server (which you should do to avoid having merge conflicts), then this option is a good solution.

Sample usage:

git init server
cd server
touch a
git add .
git commit -m 0
git config --local receive.denyCurrentBranch updateInstead

cd ..
git clone server local
cd local
touch b
git add .
git commit -m 1
git push origin master:master

cd ../server
ls

Output:

a
b

这篇关于如何推送到非Git仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆