简体   繁体   English

从本地项目文件夹推送到远程 Git 存储库

[英]Pushing to remote Git repository from local project folder

This is what I need to do.这是我需要做的。

I have a project folder in my local drive.我的本地驱动器中有一个项目文件夹。 And my local Git repository is somewhere else on the local drive.我的本地 Git 存储库位于本地驱动器上的其他位置。 I need to push the project folder to a remote Git repository.我需要将项目文件夹推送到远程 Git 存储库。 Without creating a new repository in my project folder or moving the project folder to local Git repository.无需在我的项目文件夹中创建新存储库或将项目文件夹移动到本地 Git 存储库。

I have TortoiseGit.我有 TortoiseGit。 And Eclipse with the Git plugin.以及带有 Git 插件的 Eclipse。

I mostly use Subversion (SVN).我主要使用 Subversion (SVN)。 I know the above is possible in SVN, but is it possible with Git?我知道上述内容在 SVN 中是可能的,但是在 Git 中可能吗?

From your project folder, you can use GIT_DIR to specify where your Git repository is:在您的项目文件夹中,您可以使用GIT_DIR来指定您的 Git 存储库的位置:

 cd /project/folder
 GIT_DIR=/path/to/repo/.git git add .
 GIT_DIR=/path/to/repo/.git git commit -m "my commit message"

That means you are considering your project folder as a working directory for a Git repository which is located elsewhere.这意味着您将项目文件夹视为位于其他地方的 Git 存储库的工作目录。

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

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