0

I am new to git and having a hard time keeping this organized. The way it's organized at present is I have created one repo and under this I have different sub projects. inside this projects I have code and docs as well(which I dont commit to remote but needed). The docs changes I dont want to track but i expect them to come when I create branch. If i make changes in them when I am inside a branch and then I change back the branch, i want to see them updated in other branches well. currently I just add them in "exclude" file in .git repo. is it the correct way?

redsoxlost
  • 1,215
  • 5
  • 19
  • 32

2 Answers2

3

Having one git repo with multiple projects inside it might be difficult to manage in the future.

  • Commits might get you mixed-up, which change for which project is.
  • Keeping track of your history might get messy quickly.
  • You might find it hard to change the history of one project without affecting the rest.

You can have one git repo with multiple git repos inside - this would be using git submodules.

But maybe what you want, and what would be better to manage is to have for each project a separate git repo. That way each project would be encapsulated on its own and you wold find it easier to keep track of the different projects.

Of course, if you think that you don't need that, then you don't have to make so many git projects and you can stick with your current setup.

If you don't want to track changes for a certain document or for a directory, then you can use a gitignore file. With this, you specify which documents you don't want to track.

If i make changes in them when I am inside a branch and then I change back the branch, i want to see them updated in other branches well.

Well if you change branches in your repo (or repos depending on which approach you decide to take), your changes will be only to that branch and the rest of your branches won't see those changes (unless you merge the branches).

And don't forget, there are many resources on the internet that can help you find the best way to organize each of your projects, with its own structure and everything!

mnestorov
  • 4,116
  • 2
  • 14
  • 24
  • I absolutely agree with the problems you said I might face. Commits getting mixed up and all. I am planning to create separate repos for separate projects. My local repos are having many small commits which are necessary but don't want to push to remote. Any idea how can I do so – redsoxlost Dec 10 '19 at 16:29
  • If you want to have commits that are only locally to you, then you can try to separate those commits in separate, well-named, branches. Thus in branches you do want in your remote will have the commits you want there, while the rest of your commits can stay only in your local repo. This might a bit difficult to do and to "hide" commits like that, but it can be done. The other option is to just not push to remote, but that seems a bit extreme. – mnestorov Dec 11 '19 at 07:18
0

I understand your affliction, I also wanted to have local changes always there when I am reviewing a project. But I don't want to commit my changes, why? Because it's not ready, or I'm not sure I am going to stick with it or whatever I decide to do.

So I end up with a several changes, mostly from the project I'm working on, and some from my "permanent" local changes. And I have to be careful not to pick the wrong file when staging the changes.

Rafael Oliveira
  • 309
  • 2
  • 11