Tools: Introduction to Git and Github
Source: Dev.to
Have you ever asked yourself how developers used to keep track of changes they made to files before Git?
It must have been a tedious task, saving tons of files just to track changes. For instance, a developer might save files as file001, file002, file003, and so forth. Thanks to Git and GitHub, with just a few commands a developer can save work and keep an eye on every change made to a file. Git is a version control system that allows users to track changes in files. On the other hand, GitHub is an online platform that helps developers store, share, and work together on code. Git works on your computer, while GitHub stores your Git projects on the internet. why version control is important: How to Track Changes Using Git To start tracking changes, you first need to create a Git repository. Step 1: Initialize Git Inside your project folder, run: This tells Git to start tracking the project. Step 2: Check File Status To see which files have changed: Step 3: Add Files to Staging To prepare files for saving: (The . means “add all changed files.”) Step 4: Commit Changes To save a snapshot of your work: git commit -m "Describe what you changed" A commit is like saving a checkpoint in a game—you can always return to it later. How to Push Code to GitHub Pushing means uploading your local code to GitHub. Step 1: Create a Repository on GitHub In your project folder, run: git remote add origin Step 3: Push Your Code
git push -u origin main Now your code is stored on GitHub and accessible online. How to Pull Code from GitHub Pulling means downloading the latest code from GitHub to your computer. To get updates from GitHub: Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse - Every change is recorded
- You can go back to older versions of your code
- You can see who made a change and when
- Multiple developers can work on the same project safely - Go to GitHub
- Create a new repository
- Copy the repository URL
Step 2: Connect Your Project to GitHub - You are working on multiple computers
- Other developers have made changes to the project - Git tracks changes in your files
- Version control helps you manage and recover your code
- GitHub stores your projects online
- Push uploads your code to GitHub
- Pull downloads updates from GitHub
- Commits save your progress step by step