Intro to Git and GitHub

Git is Version Control System(VCS) for tracking changes in computer files
It entails the following:

Distributed Version Control
Coordinates work between Multiple developers (Collaboration)
Who made What changes and When
Revert back at anytime (rollb…


This content originally appeared on DEV Community and was authored by samkb@420

Git is Version Control System(VCS) for tracking changes in computer files
It entails the following:

  • Distributed Version Control
  • Coordinates work between Multiple developers (Collaboration)
  • Who made What changes and When
  • Revert back at anytime (rollback)

GitHub is a for-profit company that offers a cloud-based Git repository hosting service.

Concepts of GitHub

  • Keep track of code history
  • Take 'snapshots' of your files
  • You can visit any snapshot at anytime
  • Local & Remote repositories

Lets make our hands Dirty and get Started by installing and performing basic git commands

Installation

Click on the below link it will take you to git download page then choose your OS and continue with the installation process follow the Instruction
https://git-scm.com/downloads

Getting started

Love command-line let's Dive in.?

Check Git version

$ git --version

git version 2.25.1

Configuring git on Your machine

$ git config --global user.name 'yourusername'
$ git config --global user.email 'youremail@abc.com'

$ git config --list

Need help?
git help <verb> or git <verb> --help
ie. git git help branch or git branch --help
Lets create a directory where we shall do git operation and navigate into the directory

$ mkdir Learning_git 
$ cd Learning_git

that's pretty easy,

Initializing a Git Repository

$ git init 

expected output
Initialized empty Git repository in /home/samkb420/MyHobby/Learning_git/.git/

Adding file(s) to index
let use the ls command to list file and folders.

$ ls -la

output
total 12
drwxrwxr-x 3 samkb420 samkb420 4096 Aug 19 02:14 ./
drwxrwxr-x 52 samkb420 samkb420 4096 Aug 18 19:11 ../
drwxrwxr-x 7 samkb420 samkb420 4096 Aug 19 02:14 .git/

lets create a file.
we shall build a simple calculator in python don't worry if you don't know python its not that complex.
let's open our text editor for me am using vscode.

$ touch calc.py
$ code .

let do simple add method in python

def add(a,b):

    return a + b
print(add(5,5))

having done that let do the following

$ git add -A  
$ git commit -m "[First commit #0001 ]"
$ git status 

output

On branch main
nothing to commit, working tree clean

Now lets push the code in a remote repo in this case I Will use github.
continue into github and create a repo.
lets add the github remote url
i.e
git remote add origin https://github.com/BitgritCampus/Learn_Git_Github.git

$git remote add origin remote_github_url

let now push to GitHub

git push -u origin main

Now add you credentials username and PAT(personal access token)
Hurrryy !! Done

Next on Merging.


This content originally appeared on DEV Community and was authored by samkb@420


Print Share Comment Cite Upload Translate Updates
APA

samkb@420 | Sciencx (2021-09-11T13:08:40+00:00) Intro to Git and GitHub. Retrieved from https://www.scien.cx/2021/09/11/intro-to-git-and-github/

MLA
" » Intro to Git and GitHub." samkb@420 | Sciencx - Saturday September 11, 2021, https://www.scien.cx/2021/09/11/intro-to-git-and-github/
HARVARD
samkb@420 | Sciencx Saturday September 11, 2021 » Intro to Git and GitHub., viewed ,<https://www.scien.cx/2021/09/11/intro-to-git-and-github/>
VANCOUVER
samkb@420 | Sciencx - » Intro to Git and GitHub. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/11/intro-to-git-and-github/
CHICAGO
" » Intro to Git and GitHub." samkb@420 | Sciencx - Accessed . https://www.scien.cx/2021/09/11/intro-to-git-and-github/
IEEE
" » Intro to Git and GitHub." samkb@420 | Sciencx [Online]. Available: https://www.scien.cx/2021/09/11/intro-to-git-and-github/. [Accessed: ]
rf:citation
» Intro to Git and GitHub | samkb@420 | Sciencx | https://www.scien.cx/2021/09/11/intro-to-git-and-github/ |

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.