简体   繁体   中英

How to Organize Local Git Repo

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?

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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