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.
Top comments (1)
Great thanks for the great lessons.
Waiting for the merging article lots to learn.