Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling

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 hel…


This content originally appeared on DEV Community and was authored by Romanus Onyekwere

  • 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
    Image description

  • Click 32-bit or 64 Git depending on your system RAM for window setups

  • Wait for the download to complete
    Image description
    Using Git With Command Line

  • To 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:

Image description
Configure Git

  • Now let Git know who you are.
  • This is important for version control systems, as each Git commit uses this information

Image description

  • 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 Image description
  • 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

Image description

  • 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.

Image description

  • 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

  • Click the file
    Image description

  • On the dropdown, Click Open folder

  • Scroll down and right-click on the space marked with the empty annotation
    Image description

  • 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

  • Name it Github 3
    Image description

  • Click on Select folder

  • Did you want to save the changes you make

  • Click Save
    Image description

  • Click on Yes, I trust the authors
    Image description

  • Click on Connect to open the remote Repository
    Image description
    Step 3; Git Staging Environment

  • One 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 status

  • On branch master

  • No commits yet

  • Changes to be committed:

  • (use "git rm --cached ..." to unstaged)

  • new file: index.html
    
  • Using the git bash terminal, I imputed git status
    Image description


This content originally appeared on DEV Community and was authored by Romanus Onyekwere


Print Share Comment Cite Upload Translate Updates
APA

Romanus Onyekwere | Sciencx (2024-08-03T08:15:28+00:00) Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling. Retrieved from https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/

MLA
" » Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling." Romanus Onyekwere | Sciencx - Saturday August 3, 2024, https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/
HARVARD
Romanus Onyekwere | Sciencx Saturday August 3, 2024 » Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling., viewed ,<https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/>
VANCOUVER
Romanus Onyekwere | Sciencx - » Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/
CHICAGO
" » Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling." Romanus Onyekwere | Sciencx - Accessed . https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/
IEEE
" » Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling." Romanus Onyekwere | Sciencx [Online]. Available: https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/. [Accessed: ]
rf:citation
» Setting Up Git and GitHub,Creating Repository,Making Comments,Pushing and Pulling | Romanus Onyekwere | Sciencx | https://www.scien.cx/2024/08/03/setting-up-git-and-githubcreating-repositorymaking-commentspushing-and-pulling/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.