1. WHAT IS VERSION CONTROL?
Version control is a way of keeping track of changes made to files over time. Instead of saving many copies of the same file with different names, version control helps you record each change in an organized way. This makes it easy to see what was changed, when it was changed, and to go back to an earlier version if something goes wrong. It is especially useful when working on projects that grow over time or when working with other people on the same code.
2. WHAT IS GIT?
Git is a version control system that helps developers manage and track changes in their projects.It works locally, saves snapshots of one's project and makes it easy to fix mistakes and review their work.
3. WHAT IS GITHUB?
GitHub is a website where you can store your Git projects online. It keeps your code safe, lets you share it with others, and makes it easy to work on the same project with group members. You can also access your projects from any computer, so you always have the latest version.
4. IMPORTANCE OF VERSION CONTROL
Version control is important as it helps you to:
Avoid losing your work
Undo mistakes by going back to previous versions
Track your project’s progress over time
Work on the same project from different devices
Collaborate with others without overwriting their changes
5.How to Track Changes, Push code and Pull code on Github
STEP 1: INSTALL GIT
- Go to Git’s official website and download the version suitable for your operating system.
- Run the installer and follow the steps, leave most settings as default
- After installation, open Git Bash or the command prompt and type:
git --version
This shows the version of git installed
STEP 2: CREATE A GITHUB ACCOUNT
Register or signup for a github account
Once that’s done, open your terminal (Git Bash) and set up your username and email, to allow Git to know who made changes to your files.
- Use the following commands(replace "YOUR_USERNAME" and "YOUR_EMAIL" with your details.):
git config --global user.name "YOUR_USERNAME"
git config --global user.email "YOUR_EMAIL"
STEP 3: CREATE A FOLDER FOR YOUR PROJECT
First, create a folder on your computer for your project. You can name it anything e.gtestProject.
- Then, open Git Bash and go into that folder using the cd (change directory) command:
cd testProject
This makes Git work inside that folder
STEP 4: INITIALIZE GIT
- Initialize Git in your folder using:
git init
This command makes your folder a Git project so Git can start keeping track of your files
STEP 5: ADD A NEW FILE
- To add a new file to your project, use the touch command:
touch firstfile.txt
This command creates a blank file called firstfile.txt in your folder.
- After creating the file, check which files Git is tracking using the following command:
git status
Git will show the new file in red, which means it exists but isn’t tracked yet.
Green files mean Git is watching them and will save changes when you commit.
STEP 6: TRACK AND SAVE CHANGES
- To start tracking your file, stage it using:
git add firstfile.txt
- Note:To add all files at once, use:
git add .
- save your changes with a message using:
git commit -m "Commit Message"
Use an appropriate commit message explaining clear what exactly has been done.
STEP 7: CONNECT YOUR LOCAL REPOSITORY TO GITHUB
On GitHub, create a new repository for your project.
Copy the repository URL (it looks like https://github.com/username/repository-name.git).
- Then run:
git remote add origin <paste-your-repo-link>
Remember to replace with your repository link.
Now your local folder knows where to send files online.
STEP 8: PUSH CODE
- Send your local files online using the following command:
git push origin main
STEP 9: PULL CODE
- If you want to work on the project on another computer or get the latest version, first clone the repository using:
git clone <repo-link>
cd your-project-folder
The command above copies the project from Github to your computer
- To update your local files with the latest changes from GitHub, use the command:
git pull origin main
KEY TAKEAWAY
It is much more important to understand how the git commands work than to master them
Top comments (0)