The correct way to use Git?

226 Views Asked by At

I have a bin/ folder with tons of Bash, Python scripts and some C code.

In this folder, I did:

git init
git add file_name

I thought git add . would not be good because it would think that all the different scripts and programs were part of the same commit. The git status command just scrolls off the page. When I create a branch I don't know what name to give it.

Is it better to make a folder for each individual project for code? Then run this in each folder?

git init
git add .

I think it would be easier to branch that way too. Is this useful/recommended? What are best practices

3

There are 3 best solutions below

0
On BEST ANSWER

Yes I would strongly recommend using git for each directory / project.

This will also be very helpful when you use github and move around machines as you'll be able to manage the code for each project and do things like 'git status' just to see changes for that project.

Imagine wanting to use the contents of one individual project on a new machine. If you have everything in one repository, you'll have to get it all then select what you want. There's probably smart ways around that but I always look for the most sensible KISS solution.

I wouldn't use git the way you describe. For that I would consider a more simple Dropbox or other basic cloud server storage style solution. Dropbox has security but if you need a more personalized secure solution you'll looking at more private hosting, etc.

So the answer to your question of:

"Is it better to make a folder for each individual project for code? Then run this in each folder?

git init
git add .

Is this useful/recommended?"

Is Yes!

1
On

It depends entirely on how you want to track changes to these scripts. You can git add . && git commit -s -m "initial commit" to add the lot in one go and then track future modifications to the set. Or you could create subdirectories to manage sub-sets as individual repositories and use soft-links to link from the bin folder to the actual version in use. Only you can decide really.

1
On

I am not sure if I understand your question. If you don't want to commit all the files at one time, you can use regexp with your add command if you are using linux. Then commit them.

I think commit mesh files usually happen only at the initial stage. Most time you only modify or create several files. Because you check in any single piece changes with git without much cost.