Meghna Srivastava
Frontend Developer, AUTO1 Group
hellomeghna
final draft
final draft 2
final final
final ACTUALLY FINAL
LAST FINALLLL
hellomeghna
hellomeghna
hellomeghna
hellomeghna
Git is a distributed version-control system for tracking changes in your files.
Step 0: Create a GitHub Account
Step 1: Install `git` on the local machine
Step 2: Configure git
Step 3: Generate for your machine an SSH key
git config --global user.name "Meghna Srivastava"
git config --global user.email test@example.com
hellomeghna
A repository a.k.a. repo is nothing but a collection of source code.
hellomeghna
✨ Working Directory
✨ Staging Area
✨ Local Repo (HEAD)
✨ Remote repo (MASTER)
hellomeghna
Working Directory
Local Repo (HEAD)
Staging
Remote Repo (MASTER)
git add
git pull
hellomeghna
git commit
git push
git fetch
git merge
hellomeghna
git status
fatal: not a git repository (or any of the parent directories): .git
If a project/repo HAS NO git configuration, you get:
hellomeghna
git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
If a project/repo HAS git configuration, you get:
hellomeghna
hellomeghna
hellomeghna
hellomeghna
hellomeghna
- A SHA (Secure Hash Algorithm) value is generated every time you make a commit
- Also referred as a checksum or a hash value
hellomeghna
- A long string of letters and numbers that is unique to each commit
hellomeghna
git log
commit 6aa24bb96658ce2541f69f9eccfc3d65826c726b
Author: Meghna Srivastava<test@example.com>
Date: Mon Nov 02 22:39:20 2019 -0300
Added a line
commit c861cb6c8d0f3c78b24004cfe23df55934cd3ca4
Author: Raj Saxena <anothertest@example.com>
Date: Mon Nov 02 18:20:20 2019 -0300
Created file
hellomeghna
hellomeghna
See the difference between any two commits
git diff [commit-from]..[commit-to]
git show <commit>
$ git show b10cc123
commit b10cc1238e355c02a044ef9f9860811ff605c9b4
Author: Tutorialzine
Date: Mon May 30 16:30:04 2016 +0300
Added content to hello.txt
diff --git a/hello.txt b/hello.txt
index e69de29..b546a21 100644
--- a/hello.txt
+++ b/hello.txt
@@ -0,0 +1 @@
+Nice weather today, isn't it?
hellomeghna
hellomeghna
git remote add myFirstRepo https://github.com/user/repo.git
hellomeghna
git remote add <name> <url> command takes two arguments:
A remote name, for example, “origin”
A remote URL
git remote -v verify new remote
hellomeghna
const person = {
name: 'Meghna',
age: 28,
sex: 'female'
}
const person = {
name: 'Meghna',
age: 28,
sex: 'female',
occupation: 'Developer'
}
Added one property
Local repo
const person = {
name: 'Meghna',
age: 28,
sex: 'female'
}
Server/Remote
git push
const person = {
name: 'Meghna',
age: 28,
sex: 'female',
occupation: 'Developer'
}
hellomeghna
hellomeghna
const person = {
name: 'Meghna',
age: 28,
sex: 'female'
}
const person = {
name: 'Meghna',
age: 28,
sex: 'female',
occupation: 'Developer'
}
Local repo
const person = {
name: 'Meghna',
age: 28,
sex: 'female'
}
Server/Remote
const person = {
name: 'Meghna',
age: 28,
sex: 'female',
occupation: 'Developer'
}
const person = {
name: 'Meghna',
age: 28,
occupation: 'Developer'
}
git pull
const person = {
name: 'Meghna',
age: 28,
occupation: 'Developer'
}
hellomeghna
hellomeghna
const one = 1;
const two = 2;
const one = 1;
const two = 2;
const three = 3;
const two = 2;
const threee = 3;
add line ed56f70m
remove line 5fh67bc8
git reset --hard ed56f70m
hellomeghna
git reset --hard <commit>
const one = 1;
const two = 2;
const one = 1;
const two = 2;
const three = 3;
add line ed56f70m
git reset --hard ed56f70m
hellomeghna
hellomeghna
downloads a copy of the repo in your computer
int a = 1;
int b = 2;
int c = 3;
int d = 4;
git clone <url>
int a = 1;
int b = 2;
int c = 3;
int d = 4;
hellomeghna
hellomeghna
const one = 1;
const two = 2;
const three = 3;
const one = 1;
const three = 3;
const one = 1;
const three = 3;
const four = 4;
const one = 1;
const two = 2;
master branch
hellomeghna
const one = 1;
const two = 2;
const three = 3;
const one = 1;
const two = 2;
const three = 3;
const name = 'Meggie';
const one = 1;
const two = 2;
master branch
const one = 1;
const two = 2;
const three = 3;
const four = 4;
const two = 2;
const three = 3;
const four = 4;
feature branch
bug-fix branch
hellomeghna
hellomeghna
hellomeghna
merges feature branch to current branch
const two = 2;
const three = 3;
const two = 2;
const three = 3;
const four = 4;
const one = 1;
const two = 2;
const three = 3;
const four = 4;
const two = 2;
master branch
const one = 1;
const two = 2;
const three = 3;
feature branch
hellomeghna
hellomeghna
const a = 1;
<<<<<<< HEAD
const b = 2;
=======
const b = 0;
>>>>>>> c861cb6c8d0f3c78b2
const c = 3;
const d = 4;
const e = 5;
git pull
{
your changes
{
remote changes
conflicting commit
hellomeghna
const a = 1;
const b = 2;
const c = 3;
const d = 4;
const e = 5;
git pull
{
your changes
{
remote changes
hellomeghna
hellomeghna
hellomeghna
hellomeghna
$ alias | grep -i git
lists all the git commands
ga='git add'
gaa='git add --all'
gb='git branch'
gbD='git branch -D'
gbr='git branch --remote'
gcm='git checkout master'
gcmsg='git commit -m'
gco='git checkout'
...
hellomeghna
hellomeghna
hellomeghna