Table of Contents
This is an old revision of the document!
Instruction for backup
Created by Alejandro Cabrales
Brief description of backup procedure
Each person is responsible to create a git repository under gitlab, and perform periodic backups that will be pushed towards zapad or an equivalent server. When you login into gitlab in an internet browser you will be able to see the history of your backups. Git is not easy or intuitive, but fortunately you do not need to master it to use it for common backups.
* Git is an useful but quite a complex tool. This instructions do not pretend to be more than 1% exhaustive. Some people claim that, after 5 or more years using git they do not get a full grasp (do not look at me; I have spend a little bit less than two years!) Internet is your friend, so look there for answers when requiring something more complex than what I present in this tutorial (or make an appointment with Bob).
1. Creating a Git repository
- You first choose the folder where you will create your repository. If you are afraid and need some practice, you can start with an empty folder. Get into that folder and type
- This command will create a hidden file named .git, which will contain the different commits that you make (do not worry if you do not understand what a commit is. Hopefully it will be clear as you read more… and practice!).
2. Add files that you want to include into the backup
- Now it is time to add the files that you want to track for backups. Here you can add both files and directories. Do not add anything that you do not want in the backup.
- For the practice, create two text files in your empty directory, say myfile1.txt and myfile2.txt. Then add the former using
git add myfile1.txt
- You can type “git status” to verify that myfile1.txt was added and ready to be committed, whereas myfile2.txt remains untracked. Here myfile1.txt represents files and folders suitable for being backup, such as source codes, makefiles and possibly parameters files. On the contrary, myfile2.txt represents all that you should not incorporate into the backup, such as binaries, results, etc.
3. Commit your changes
- Once you added the files, you create the local backup using git commit:
git commit -m "This is my backup"
- Notice that I have added label “-m” which allows to write a message or comment associated to the backup. I strongly recommend you to take advantage of this, for it is easy to lose track of the changes that one makes in one's codes. If you are constantly changing you code, either debugging or testing, it can be wise to commit, for instance, before any “major surgery” that you are palling in your codes, commenting the current status and what you are about to do.
4. Create remote repository (you make this only once)
- The final step is to push the local repository to the server. However, you must first create the remote repository towards which you will push. Please take a look at this simple tutorial to learn how to create it: new.git.project.pdf
5. Push to remote repository
- The final step is to push the local repository to the server. Simply type
- If you get no error message, congratulations! Your commits went to the remote repository.