如何在没有适当的git服务器的情况下使用git? [英] How do I use git without having a proper git server?

查看:96
本文介绍了如何在没有适当的git服务器的情况下使用git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在Windows环境中备份项目,而无需手动复制和粘贴整个文件夹.不幸的是,我不允许为此项目使用远程git服务器,因此我想知道是否可以使用git在备份的硬盘驱动器上备份我的项目.

I want to be able to make backups of my project in a windows environment without having to manually copy and paste my whole folder. Unfortunately I am not allowed to use a remote git server for this project, so I was wondering if I could use git for backing up my project on a mounted hard drive.

我已经尝试过解决方案:

git remote add Y file:///path/to/Y

但是,当我尝试推动时,我收到此错误:

However, when I try to push I receive this error:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我试图在安装的设备和本地目录上初始化一个裸存储库,但是遇到了同样的错误.

I tried to init a bare repository on my mounted device and local directory but I faced the same error.

总而言之,我希望能够在Windows环境中自动备份项目,或者使用诸如git commit和git push之类的少量命令来备份我的项目.有什么想法吗?

Summarizing, I want to be able to backup my project in a windows environment automatically or with few commands such as git commit and git push. Any ideas?

推荐答案

这是我的工作,据我所知,这是可行的:

Here is what I did and what as far as I know works:

首先,您创建一个git repo:

First you create a git repo:

cd e:/tmp 
mkdir backup
cd backup
git --bare init

现在已经创建了git存储库,您需要转到文件.

Now the git repository was created you need to go to your files.

假设您使用xampp,并且想要从一个项目中进行备份.

Let's say you use xampp and you want a backup from one of your projects.

cd e:/xampp/htdocs/project
git init
git add .
git remote add backup e:/tmp/backup
git commit -m "First commit"
git push backup master

Boom现在将所有内容保存到备份到master分支中;) 您甚至可以在不同的高清硬盘中执行此操作……这就是我将代码在家中4免费跟踪到备份高清硬盘中的方式.

Boom now it saved everything into your backup into master branch ;) You can even do it in different HDs... that's how I keep code tracked at home 4 free into my backup HD.

希望这也会对以后的人有所帮助.

Hope this help someone else in future as well.

再见! ;)

这篇关于如何在没有适当的git服务器的情况下使用git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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