简体   繁体   English

在git存储库中处理项目(文件夹)而无需克隆整个存储库? GIT

[英]Working on a project (folder) in a git repository without having to clone the entire repo? GIT

I have a git repository call it repoA with 5 projects (or five folders). 我有一个git存储库,将其称为repoA,其中包含5个项目(或5个文件夹)。

Project 1 项目1

Project 2 项目二

Project 3 项目3

Project 4 专案4

Project 5 项目5

I am currently working on say project 5, a developer on my team has worked on that project, but instead of committing/pushing to our git repo, they have just given me the Project 5 folder directly. 我目前正在研究项目5,我团队的开发人员已经在该项目上工作,但是他们没有提交/推送到我们的git repo,而是直接给了我Project 5文件夹。 I have worked on it, fixed things, its working but now I want to commit this project to the repo but I cannot do so without cloning the entire thing to a local folder then copying the contents of the project 5 folder into that repoA folder (overwriting it) and comitting that one. 我已经对其进行了工作,修复了它的工作,但是现在我想将该项目提交到存储库,但是如果不将整个对象克隆到本地文件夹,然后将项目5文件夹的内容复制到该repoA文件夹中,则无法这样做。覆盖它)并提交。

The issue is that I do not want to do this for every change because it doesn't make sense. 问题是我不想为每个更改都这样做,因为这没有意义。 Is there anyway to get around this problem without having to clone the entire repo? 无论如何,无需克隆整个存储库就能解决此问题? I do not want to re-import a project in my IDE. 我不想在我的IDE中重新导入项目。

Can I just create a new branch, commit to project 5 folder from a different local folder (that my IDE has open)? 我可以只创建一个新分支,然后从另一个本地文件夹(IDE已打开)提交到Project 5文件夹吗?

If you do not want to clone, you can simply copy repo folder from any of your colleague and then simply do : 如果您不想克隆,则可以简单地从任何同事那里复制repo文件夹,然后执行以下操作:

git pull on master branch. git pull master分支。

then create new feature branch for the changes/fixes you want to do from master branch. 然后为要从master分支进行的更改/修复创建新功能分支。

 git checkout -b my_feature master

Then simply push the branch : 然后只需推动分支:

git push origin my_feature

You should not confuse folders projects with fixes you made. 您不应将文件夹项目与所做的修订混淆。 Git has a totally different workflow, it looks like you are new to git and have a habit of SVN like VCS. Git拥有完全不同的工作流程,看起来您是git的新手,并拥有像VCS这样的SVN习惯。

Please note that you no longer need to clone repo everytime you do a fix. 请注意,您不再需要在每次修复后克隆仓库。 All you ned to do is go to master branch of your project,take latest code( git pull ) and create feature branch( git checkout -b my_feature master ) do the fix and push this branch to remote. 您要做的只是进入项目的master分支,获取最新代码( git pull )并创建feature分支( git checkout -b my_feature master )进行修复,然后将此分支推送到远程。

You may want to visit this interactive tutorial first before actually enjoying git. 在实际享受git之前,您可能需要先访问交互式教程。

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

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