Git best practices & FAQ¶
Mis à jour il y a plus de 2 ans
- Git best practices & FAQ
- Can I have my project's git repository hosted by the IT department?
- Can I have a "personal" git repo in my home directory on atlas?
- What is the maximum size for a git repository?
- Are there files that I should avoid putting in a git repository?
- So where can I put data files?
- How can I get a project space?
- Why do big files cause problems in git?
- Why shouldn't I issue git commands on ssh.pasteur.fr?
- So, how can I clone and do any operation on the git repository that is in my HOME?
- How to mount my home directory?
- How to avoid commiting certain types of files?
- I made a mistake and pushed a big data file to my git repo; what can I do?
Can I have my project's git repository hosted by the IT department?¶
Yes, there already are projects here: https://gitlab.pasteur.fr/.
Please always sign in with your Pasteur account or else you won't be able to create new repositories.
Once you log in with a GitHub or a Google account, you become an external user and lose your project management privileges.
Then you have to contact firstname.lastname@example.org to ask an Administrator to change your status.
Can I have a "personal" git repo in my home directory on atlas?¶
What is the maximum size for a git repository?¶
Officially, there is no maximum size but when repositories become too big, problems arise.
A reasonable size for a git repository is approx 1GB.
Are there files that I should avoid putting in a git repository?¶Yes
- data files,
- binary files,
- files bigger than 1 MB
should not be put in a git repository.
So where can I put data files?¶
- In your home directory if you are the only person who need access to it.
- In a project space if other persons need access to it.
How can I get a project space?¶
Send an email to email@example.com
Why do big files cause problems in git?¶
Because git makes all its file comparisons in memory. So you are likely to have problems since memory is limited on machines.
Why shouldn't I issue git commands on ssh.pasteur.fr?¶
Because it may require a lot of memory if you have big files and that may crash the machine. Remember that that machine is used by many people.
So, how can I clone and do any operation on the git repository that is in my HOME?¶
Mount your home on your personal computer or workstation and access it as if it was located on your machine.
git clone path_to_mounted_home_on_my_machine/my_git_repo.git my_local_repo
Example on OS X:
git clone /Volumes/\@home/path/to/the/git/repo/my_git_repo.git my_local_repo
You can also use git over ssh (if your repo is of reasonnable size):
git clone yourlogin@remote/path/to/the/git/repo
git clone firstname.lastname@example.org:/path/to/the/git/repo/ my_local_repo
: regarding the Pasteur GitLab, you have to create an ssh key before being able to clone a repository. Once done, you can do
git clone email@example.com:yourlogin/your_repo.git my_local_repo
How to mount my home directory?¶
From Windows and OS X, machines with the Pasteur homemade master should already have a shortcut to
@home. If not, send an email to firstname.lastname@example.org
On Linux, have a look at https://projets.pasteur.fr/projects/linux-pasteur/wiki
How to avoid commiting certain types of files?¶
You can use a .gitignore file. Do some google search to see how. It is explained at many places. For example: https://github.com/github/gitignore
I made a mistake and pushed a big data file to my git repo; what can I do?¶The problem is that even if you remove the file, it will stay in git history. So the repository will remain big.
You can either:
- (easiest way) create a new git repository where you will put only the necessary files and not the big one,
- rewrite history. You can use the BFG Repo-Cleaner . Other people using the repo will have to git clone it again if you do that.