Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling
Romanus Onyekwere
Posted on August 3, 2024
- Git is a distributed version control system used to track changes in source code during software development.
- It allows multiple developers to collaborate on a project, manage different versions of the code, and maintain a history of changes.
- It helps in tracking code and who made the changes What Does Git Do ?
- Manage projects with Repositories
- Clone a project to work on a local copy
- Control and track changes with Staging and Committing
- Branch and Merge to allow for work on different parts and versions of a project
- Pull the latest version of the project to a local copy
- Push local updates to the main project
Working With Git
Initialize Git on a folder, making it a Repository
- Git now creates a hidden folder to keep track of changes in that folder
- When a file is changed, added or deleted, it is considered modified
- You select the modified files you want to Stage
- The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
- Git allows you to see the full history of every commit.
- You can revert back to any previous commit.
Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!
GitHub is a web-based platform that uses Git for version control and collaboration.
It provides a place to store Git repositories online, along with tools for collaboration, such as issue tracking and pull requests
Git is not the same as GitHub.
GitHub makes tools that use Git.
Step 1; Install Git
On Google browser, type git-scm.com/download
Click on Windows, Linux or Mac depending on your versionfor Download
Click 32-bit or 64 Git depending on your system RAM for window setups
Wait for the download to complete
Using Git With Command LineTo start using Git, we are first going to open up our Command shell.
For Windows, you can use Git bash, which comes included in Git for Windows. For Mac and Linux you can use the built-in terminal.
The first thing we need to do is to check if Git is properly installed:
- Now let Git know who you are.
- This is important for version control systems, as each Git commit uses this information
- Change the user name and e-mail address to your own. You will probably also want to use this when registering to GitHub later on.
Creating Git Folder
- Now, let's create a new folder for our project
- mkdir---- make a new directory
- cd------- changes the current working directory
- Now that we are in the correct directory.
- We can start by initializing Git!
- If you already have a folder/directory you would like to use for Git
- Navigate to it in the command line, or open it in your file explorer, right-click and select Git Bash Initialize Git
- Once you have navigated to the correct folder, you can initialize Git on that folder
- First Git Repository is just created
- Git now knows that it should watch the folder you initiated it on.
- Git creates a hidden folder to keep track of changes. Step 2; Git New Folder
- You just created your first local Git repository. But it is empty.
- So let's add some files, or create a new file using your favourite text editor.
- Then save or move it to the folder you just created
- For this example, I am going to use a simple HTML file like this
<!DOCTYPE html>
Hello Romanus!
Hello Romanus!
This is the first assignment on Github.
- Save it to our new folder as index.html.
- Go back to the terminal and list the files in the current working directory
Then I check the Git status and see if it is a part of the repository
Now Git is aware of the file, but has not added it to our repository!
Files in the Git repository folder can be in one of 2 states
Tracked - files that Git knows about and are added to the repository
Untracked - files that are in your working directory, but not added to the repository
** Open Another Folder**At the top right corner of Vscode
On the dropdown, Click Open folder
Scroll down and right-click on the space marked with the empty annotation
You will see small box with lots of icon
Take your cursor down to New
To the right of the box, Click on folder Icon
The New folder is Created
Click on Select folder
Did you want to save the changes you make
Click on Connect to open the remote Repository
Step 3; Git Staging EnvironmentOne of the core functions of Git is the concepts of the Staging Environment and the Commit.
As I am working, I may be adding, editing and removing files.
But whenever finish a part of the work, I should add the files to a Staging Environment.
Staged files are files that are ready to be committed to the repository I am working on.
For now, I am done working with index.html.
So I can add it to the Staging Environment
git statusOn branch master
No commits yet
Changes to be committed:
(use "git rm --cached ..." to unstaged)
new file: index.html
Posted on August 3, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.