What is Git?
Git is a version control system (VCS) for tracking changes in computer files.
How does this help?
The pain of having backing your files manually on an external hard drive is updating it. There’s so many scenarios:
- It’s been a hot minute since you’ve backed up your files. You don’t remember which files need to be updated in the external.
- You reorganized your files. It’d be a pain to reorganize the files in the external too.
- Dragging and dropping in the right place is too much work.
So how does git help?
Git keeps track of changes in your computer as versions. Git will note what version your external hard drive left off at. When it’s time to update your external, git knows exactly what files have changed.
Let’s Get Started
For the purpose of this demonstration, I will be backing up all my media files from the sd card to an external hard drive.
No internet connection will be required here.
Table of Contents:
- Install Git
- Initialize Git
- Commit your changes (Repeating Step)
- Clone to your external (One-time)
- Update your external
Step 1: Install Git
If you don’t have git already installed, go ahead and download it from their website. The installation should be pretty straightforward.
If git is successfully installed, you should be able to open Terminal or Command Prompt and execute git --version
Step 2: Initialize Git
The next step is to initialize git in the folder you want to back up.
cd
or ‘change directory’ to your folder of interest- initialize git by typing
git init
A new folder called .git
should appear in that folder now. This is where git will keep track of all the changes.
Step 3: Commit your changes (Repeating Step)
The next step is to “commit” your changes. This will be a reoccurring step whenever you want to essentially “save.”
git add .
→ This will add every file that’s been changed to the staging processgit commit -m "note_what_changed"
→ This commits all the files in the staging process. Write what’s new in the quotation marks
That’s it! You’ve saved all your changes. Now it’s time to reflect those changes to the external.
Additional Notes:
- You can use
git status
to check what files need to be staged and which files need to be committed
Step 4: Clone to your external (One time)
The first step to back up your folder in your external hard drive is to clone the repository we initialized in the sd card.
cd
or change directory to the external hard drivegit clone 'filepath/sd_card/.git'
clone the repository from the filepath- make sure you
cd
into the folder that was copied
Step 5: Update your external
The last step is what you all came here for, update your external hard drive.
Let’s say you just added a NEW PICTURE.jpg
into the sd card. Go ahead and repeat Step 3: Commit your changes
Now you can reflect those changes to your external by simply typing git pull
You’re done! It’s that simple! This is extremely powerful when you have tons of files and can’t keep track of every minor change.
Please please let me know if you’re having trouble or have better suggestions. Let’s have a discussion :)
Ending Notes
Thank you so much for taking the time to read this! Please feel free to comment and let me know if you want a YouTube tutorial on this 👀.
Also checkout my website (eellaup.com)! I made it with ReactJS and deployed it on Github. P.S. I have no background in this stuff so it’s still a work in progress :)