0

I have a git repository call it repoA with 5 projects (or five folders).

Project 1

Project 2

Project 3

Project 4

Project 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. 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.

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.

Can I just create a new branch, commit to project 5 folder from a different local folder (that my IDE has open)?

Soorman
  • 19
  • 1
  • 1
    Possible duplicate of [How do I clone a subdirectory only of a Git repository?](https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository) – Harald Nordgren May 13 '18 at 18:04

1 Answers1

0

If you do not want to clone, you can simply copy repo folder from any of your colleague and then simply do :

git pull on master branch.

then create new feature branch for the changes/fixes you want to do from master branch.

 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.

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.

You may want to visit this interactive tutorial first before actually enjoying git.

beingmanish
  • 1,040
  • 8
  • 21
  • >If you do not want to clone, you can simply copy repo folder from any of your colleague and then simply do : That's the thing. My colleague did not give me a repo folder, but just the folder of project 5. So when I opened it in my IDE i already made changes. – Soorman May 13 '18 at 18:29
  • Is the only option to copy that project folder to a repo folder and re-import the project? – Soorman May 13 '18 at 18:30
  • yes, for the very first time only you need to clone(or copyroot project from coleage and do git pull) the root project; the work. It's pretty simple. Never ever try tocompare git with SVN like older tools, you will be confused (like you a here). I would recommend first learn git and then only frame your problem, then you will realize that was not at all any problem just a confusion. – beingmanish May 13 '18 at 18:48