SlideShare a Scribd company logo
GIT
COMMANDES ET MEMENTO
@ElZakaria
 Set up your information, really important.
$ git config --global user.name ‘’ElZakaria"
$ git config --global user.email preemptif@gmail.com

If you want to override this with a different name
or e-mail address for specific projects, you can
run the command without the --global option
when you’re in that project.

YOUR IDENTITY!!!!
Now that your identity is set up, you can
configure the default text editor that will
be used when Git needs you to type in a
message. By default, Git uses your
system’s default editor
$ git config --global core.editor emacs


$git config --list to Check your settings.
$ git config user.name to check for a specific key

See some configs values


If you ever need help while using Git,
there are three ways to get the manual
page (manpage) help for any of the Git
commands:

$ git help <verb>
 $git <verb> --help
 $man git-<verb>


Linux

Wanna get some help? [RTFM]


The main tool you use to determine which
files are in which state is the git status
command.
$ git status # On branch master
…..

If any change to the TRACKED files are done,
it will be show there before commiting them!

Check the status of your files


When you clone a repo, all the files are by
default tracked, but adding new ones are not
tracked even if is added since the last
snapshot, you should do it explicitly:

$ git add MyFile.txt
The git add command takes a path name for
either a file or a directory; if it’s a directory,
the command adds all the files in that
directory recursively.

Begin to track a new File
FOLDER
(Working
Directory)

add

Index
(Staging
Area)

git add command (it’s a multipurpose
command —
you use it to begin tracking new
files, to stage files,
and to do other things like marking
merge-conflicted
files as resolved).

commit

HEAD

Trees maintained by GIT!


To see what you’ve changed but not yet
staged, type git diff with no other
arguments:
$ git diff
diff --git a/MYFILE.txt b/MYFILE.txt
index 778f824..ab9e1ea 100644
--- a/MYFILE.txt
+++ b/MYFILE.txt
@@ -1,3 +1,4 @@
content added!
Oups forgot this sentence
-Once again, sorry I had a terrible morning
 No newline at end of file
+Once again, sorry I had a terrible morning
+m
 No newline at end of file

Details: Changed and not staged


If you want to see what you’ve staged
that will go into your next commit, you
can use git diff --cached. (In Git versions
1.6.1 and later, you can also use git diff -staged, which may be easier to
remember.) This command compares your
staged changes to your last commit:
$git diff --staged

Details: changed AND Staged


To commit what you’ve changed:

$git commit
OR
$git commit –m ‘’ Description message ‘’
OR
Put the diff in
description
$git commit …. -v
ElZakaria@ELDEV ~/projet1 (master)
$ git commit -m "Mon changement à Moi"
[master 54d99c0] Mon changement à Moi
1 file changed, 5 insertions(+)
create mode 100644 MYFILE.txt

SHA-1
Checksum’s
Commit

Commiting the changes locally.
$git commit –a –m ‘’blah blah blah’’


Providing the -a option to the git commit
command makes Git automatically stage
every file that is already tracked before
doing the commit, letting you skip the
git add part.

Skipping the Staging Area
If you simply remove the file from your working
directory, it shows up under the “Changes not
staged for commit”
You have to add it $git add …
Now you may want to use git rm to don’t track it:
$git rm MYFILE.TXT


If you modified the file and added it to the index
already, you must force the removal with the -f
option. This is a safety feature to prevent
accidental removal of data that hasn’t yet been
recorded in a snapshot and that can’t be
recovered from Git.


Another useful thing you may want to do
is to keep the file in your working tree but
remove it from your staging area.

$ git rm --cached readme.txt



You can pass files, directories, and fileglob patterns to the git rm command!!!

KEEP The file, remove from index
$git mv file_FROM file_TO
Same as...

$ mv README.txt README
$ git rm README.txt
$ git add README

Moving Files with GIT


After you have created several commits,
or if you have cloned a repository with an
existing commit history, you’ll probably
want to look back to see what has
happened. The most basic and powerful
tool to do this is the git log command.
$git log

Viewing the commit History


A huge number and variety of options.



One of the more helpful options is -p, which shows
the diff introduced in each commit. You can also
use -2, which limits the output to only the last two
entries

$git log –p -2

$git log --word-diff

Difference in
words not lines!

$git log -–stat
The --stat option prints below each commit entry a list of modified files,
how many files were changed, and how many lines in those files were
added and removed. It also puts a summary of the information at the
end.
Short
Full
fuller
oneline

$ git log --pretty=oneline
$ git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the verison number
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test code
a11bef06a3f659402fe7563abf99ad00de2209e6 first commit

$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 11 months ago : changed the version number
085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code
a11bef0 - Scott Chacon, 11 months ago : first commit

Descendant
order

Formatting the commit History
Most useful option for format
P.S : --graph option is also interesting [Branch and merges…]

Most useful option for format


-(n) : Show only the last n commits



--since, --after : Limit the commits to
those made after the specified date.
$ git log --since=2.weeks

This command works with lots of formats
— you can specify a specific date (“200801-15”) or a relative date such as “2
years 1 day 3 minutes ago”.

Limiting Log Output


--author : allows you to filter on a specific
author.



--grep : lets you search for keywords in the
commit messages.

Note :
if you want to specify both author and grep
options, you have to add --all-match or the
command will match commits with either.
Others: --commiter: ….

Limiting Log Output


Gitk is basically a visual git log tool, and it
accepts nearly all the filtering options that
git log does. If you type gitk on the
command line in your project:

Gitk accept nearly all filtering git log options!

See logs visually!


One of the common undos takes place when
you commit too early and possibly forget to
add some files, or you mess up your commit
message.
$ git commit --amend

$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend

Changing Your Last Commit
# Changes to be committed:
 # (use "git reset HEAD <file>..." to
unstage) #
 # modified: README.txt
 # modified: benchmarks.rb


git reset HEAD benchmarks.rb

Unstaging a staged file
# Changes not staged for commit:
# (use "git add <file>..." to update what will be
committed)
 # (use "git checkout -- <file>..." to discard changes
in working directory)
 # # modified: benchmarks.rb #










$ git checkout -- benchmarks.rb
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage) #
# modified: README.txt

Discard the changes


Anything that is committed in Git can
almost always be recovered. Even
commits that were on branches that were
deleted or commits that were overwritten
with an --amend commit can be
recovered.



Anything you lose that was never
committed is likely never to be seen
again.

YOU Should Understand this


To see which remote servers you have
configured, you can run the git remote
command. It lists the shortnames of each
remote handle you’ve specified.
$ git remote
origin

$ git remote -v
origin git://github.com/schacon/ticgit.git
(fetch)
origin git://github.com/s…/ticgit.git (push)

Showing Your Remotes
$ git remote add pb
git://github.com/paulboone/ticgit.git

shortname

$ git remote -v
origin git://github.com/schacon/ticgit.git
pb git://github.com/paulboone/ticgit.git
$git remote add [shortname] [url]

Adding remote repositories
$ git fetch [remote-name]
Goes to the server and get any new work, but
doesn’t merge anything, you have to do it
manually!
If you have a branch set up to track a remote
branch, you can use the git pull command to
automatically fetch and then merge a
remote branch into your current branch.
$git pull [remote-name]

Fetching and pulling from remotes
$git push [remote-name] [branch-name]
$ git push origin master
This command works only if you cloned from a
server to which you have write access and if
nobody has pushed in the meantime. If you
and someone else clone at the same time and
they push upstream and then you push
upstream, your push will rightly be rejected.
You’ll have to pull down their work first and
incorporate it into yours before you’ll be
allowed to push.

Push to the server
$ git remote show origin
• remote origin URL:
git://github.com/schacon/ticgit.git
Remote branch merged with 'git pull'
while on branch master
master
Tracked remote branches
master
ticgit

Inspecting a remote
$ git remote rename pb paul
$ git remote
origin
Paul
$ git remote rm paul
$ git remote
origin

Removing and Renaming Remotes

More Related Content

What's hot

Tech thursdays / GIT
Tech thursdays / GITTech thursdays / GIT
Tech thursdays / GIT
Marek Prochera
 
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
betabeers
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a git
Berny Cantos
 
15 3. modulization
15 3. modulization15 3. modulization
15 3. modulization
웅식 전
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
siva ram
 
Command cheatsheets mac
Command cheatsheets macCommand cheatsheets mac
Command cheatsheets mac
Paal Ringstad
 
Command cheatsheets windows
Command cheatsheets windowsCommand cheatsheets windows
Command cheatsheets windows
Paal Ringstad
 
Windows Cheatsheet
Windows CheatsheetWindows Cheatsheet
Windows Cheatsheet
Joy Seng
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Git
fajran
 
Mac Linux Commands cheatsheet
Mac Linux Commands cheatsheetMac Linux Commands cheatsheet
Mac Linux Commands cheatsheet
Joy Seng
 
Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.
Pitambar Jha
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
Luis Lamadrid
 
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
Engr. Md. Jamal Uddin Rayhan
 

What's hot (13)

Tech thursdays / GIT
Tech thursdays / GITTech thursdays / GIT
Tech thursdays / GIT
 
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a git
 
15 3. modulization
15 3. modulization15 3. modulization
15 3. modulization
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Command cheatsheets mac
Command cheatsheets macCommand cheatsheets mac
Command cheatsheets mac
 
Command cheatsheets windows
Command cheatsheets windowsCommand cheatsheets windows
Command cheatsheets windows
 
Windows Cheatsheet
Windows CheatsheetWindows Cheatsheet
Windows Cheatsheet
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Git
 
Mac Linux Commands cheatsheet
Mac Linux Commands cheatsheetMac Linux Commands cheatsheet
Mac Linux Commands cheatsheet
 
Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.Git a stupid change tracker and persistent map.
Git a stupid change tracker and persistent map.
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
 
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Pr...
 

Viewers also liked

Git Introduction
Git IntroductionGit Introduction
Git Introduction
loremipsum123
 
Git - Introduction and Overview
Git - Introduction and OverviewGit - Introduction and Overview
Git - Introduction and Overview
asmajlovic
 
Basic Git commands
Basic Git commandsBasic Git commands
Basic Git commands
Jitendra Zaa
 
git command
git commandgit command
git command
LearningTech
 
Basics About Git & GitHub
Basics About Git & GitHubBasics About Git & GitHub
Basics About Git & GitHub
Raiful Hasan
 
Version control system
Version control systemVersion control system
Version control system
Andrew Liu
 
A practical approach to version control for SQL Server - By Steve Jones
A practical approach to version control for SQL Server - By Steve JonesA practical approach to version control for SQL Server - By Steve Jones
A practical approach to version control for SQL Server - By Steve Jones
Red Gate Software
 

Viewers also liked (7)

Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git - Introduction and Overview
Git - Introduction and OverviewGit - Introduction and Overview
Git - Introduction and Overview
 
Basic Git commands
Basic Git commandsBasic Git commands
Basic Git commands
 
git command
git commandgit command
git command
 
Basics About Git & GitHub
Basics About Git & GitHubBasics About Git & GitHub
Basics About Git & GitHub
 
Version control system
Version control systemVersion control system
Version control system
 
A practical approach to version control for SQL Server - By Steve Jones
A practical approach to version control for SQL Server - By Steve JonesA practical approach to version control for SQL Server - By Steve Jones
A practical approach to version control for SQL Server - By Steve Jones
 

Similar to Git Memento of basic commands

Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Git and Github
Git and GithubGit and Github
Git and Github
Teodora Ahkozidou
 
Git and github
Git and githubGit and github
Git and github
Teodora Ahkozidou
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
Peter Carenza
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
Nyros Technologies
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git
GitGit
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
DrupalCafe5 VCS
DrupalCafe5 VCSDrupalCafe5 VCS
DrupalCafe5 VCS
Yuriy Gerasimov
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Git
GitGit
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
Terry Wang
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Git learning
Git learningGit learning
Git learning
Amit Gupta
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
Tagged Social
 

Similar to Git Memento of basic commands (20)

Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and github
Git and githubGit and github
Git and github
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
 
Git github
Git githubGit github
Git github
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git
GitGit
Git
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
DrupalCafe5 VCS
DrupalCafe5 VCSDrupalCafe5 VCS
DrupalCafe5 VCS
 
Git commands
Git commandsGit commands
Git commands
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git introduction
Git introductionGit introduction
Git introduction
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git learning
Git learningGit learning
Git learning
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 

More from Zakaria Bouazza

Glassfish 4 quick guide
Glassfish 4 quick guideGlassfish 4 quick guide
Glassfish 4 quick guide
Zakaria Bouazza
 
Page viewer sous android
Page viewer sous androidPage viewer sous android
Page viewer sous android
Zakaria Bouazza
 
Action bar sous Android
Action bar sous AndroidAction bar sous Android
Action bar sous Android
Zakaria Bouazza
 
Success insights
Success insightsSuccess insights
Success insights
Zakaria Bouazza
 
Méthodologie 2 Track Unified Process
Méthodologie 2 Track Unified ProcessMéthodologie 2 Track Unified Process
Méthodologie 2 Track Unified Process
Zakaria Bouazza
 
Brevets
BrevetsBrevets
Présentation de RMI Java
Présentation de RMI JavaPrésentation de RMI Java
Présentation de RMI JavaZakaria Bouazza
 

More from Zakaria Bouazza (7)

Glassfish 4 quick guide
Glassfish 4 quick guideGlassfish 4 quick guide
Glassfish 4 quick guide
 
Page viewer sous android
Page viewer sous androidPage viewer sous android
Page viewer sous android
 
Action bar sous Android
Action bar sous AndroidAction bar sous Android
Action bar sous Android
 
Success insights
Success insightsSuccess insights
Success insights
 
Méthodologie 2 Track Unified Process
Méthodologie 2 Track Unified ProcessMéthodologie 2 Track Unified Process
Méthodologie 2 Track Unified Process
 
Brevets
BrevetsBrevets
Brevets
 
Présentation de RMI Java
Présentation de RMI JavaPrésentation de RMI Java
Présentation de RMI Java
 

Recently uploaded

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
dot55audits
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 

Recently uploaded (20)

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 

Git Memento of basic commands

  • 2.  Set up your information, really important. $ git config --global user.name ‘’ElZakaria" $ git config --global user.email preemptif@gmail.com If you want to override this with a different name or e-mail address for specific projects, you can run the command without the --global option when you’re in that project. YOUR IDENTITY!!!!
  • 3. Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message. By default, Git uses your system’s default editor $ git config --global core.editor emacs  $git config --list to Check your settings. $ git config user.name to check for a specific key See some configs values
  • 4.  If you ever need help while using Git, there are three ways to get the manual page (manpage) help for any of the Git commands: $ git help <verb>  $git <verb> --help  $man git-<verb>  Linux Wanna get some help? [RTFM]
  • 5.  The main tool you use to determine which files are in which state is the git status command. $ git status # On branch master ….. If any change to the TRACKED files are done, it will be show there before commiting them! Check the status of your files
  • 6.  When you clone a repo, all the files are by default tracked, but adding new ones are not tracked even if is added since the last snapshot, you should do it explicitly: $ git add MyFile.txt The git add command takes a path name for either a file or a directory; if it’s a directory, the command adds all the files in that directory recursively. Begin to track a new File
  • 7. FOLDER (Working Directory) add Index (Staging Area) git add command (it’s a multipurpose command — you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved). commit HEAD Trees maintained by GIT!
  • 8.  To see what you’ve changed but not yet staged, type git diff with no other arguments: $ git diff diff --git a/MYFILE.txt b/MYFILE.txt index 778f824..ab9e1ea 100644 --- a/MYFILE.txt +++ b/MYFILE.txt @@ -1,3 +1,4 @@ content added! Oups forgot this sentence -Once again, sorry I had a terrible morning No newline at end of file +Once again, sorry I had a terrible morning +m No newline at end of file Details: Changed and not staged
  • 9.  If you want to see what you’ve staged that will go into your next commit, you can use git diff --cached. (In Git versions 1.6.1 and later, you can also use git diff -staged, which may be easier to remember.) This command compares your staged changes to your last commit: $git diff --staged Details: changed AND Staged
  • 10.  To commit what you’ve changed: $git commit OR $git commit –m ‘’ Description message ‘’ OR Put the diff in description $git commit …. -v ElZakaria@ELDEV ~/projet1 (master) $ git commit -m "Mon changement à Moi" [master 54d99c0] Mon changement à Moi 1 file changed, 5 insertions(+) create mode 100644 MYFILE.txt SHA-1 Checksum’s Commit Commiting the changes locally.
  • 11. $git commit –a –m ‘’blah blah blah’’  Providing the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part. Skipping the Staging Area
  • 12. If you simply remove the file from your working directory, it shows up under the “Changes not staged for commit” You have to add it $git add … Now you may want to use git rm to don’t track it: $git rm MYFILE.TXT  If you modified the file and added it to the index already, you must force the removal with the -f option. This is a safety feature to prevent accidental removal of data that hasn’t yet been recorded in a snapshot and that can’t be recovered from Git.
  • 13.  Another useful thing you may want to do is to keep the file in your working tree but remove it from your staging area. $ git rm --cached readme.txt  You can pass files, directories, and fileglob patterns to the git rm command!!! KEEP The file, remove from index
  • 14. $git mv file_FROM file_TO Same as... $ mv README.txt README $ git rm README.txt $ git add README Moving Files with GIT
  • 15.  After you have created several commits, or if you have cloned a repository with an existing commit history, you’ll probably want to look back to see what has happened. The most basic and powerful tool to do this is the git log command. $git log Viewing the commit History
  • 16.  A huge number and variety of options.  One of the more helpful options is -p, which shows the diff introduced in each commit. You can also use -2, which limits the output to only the last two entries $git log –p -2 $git log --word-diff Difference in words not lines! $git log -–stat The --stat option prints below each commit entry a list of modified files, how many files were changed, and how many lines in those files were added and removed. It also puts a summary of the information at the end.
  • 17. Short Full fuller oneline $ git log --pretty=oneline $ git log --pretty=oneline ca82a6dff817ec66f44342007202690a93763949 changed the verison number 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test code a11bef06a3f659402fe7563abf99ad00de2209e6 first commit $ git log --pretty=format:"%h - %an, %ar : %s" ca82a6d - Scott Chacon, 11 months ago : changed the version number 085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code a11bef0 - Scott Chacon, 11 months ago : first commit Descendant order Formatting the commit History
  • 18. Most useful option for format
  • 19. P.S : --graph option is also interesting [Branch and merges…] Most useful option for format
  • 20.  -(n) : Show only the last n commits  --since, --after : Limit the commits to those made after the specified date. $ git log --since=2.weeks This command works with lots of formats — you can specify a specific date (“200801-15”) or a relative date such as “2 years 1 day 3 minutes ago”. Limiting Log Output
  • 21.  --author : allows you to filter on a specific author.  --grep : lets you search for keywords in the commit messages. Note : if you want to specify both author and grep options, you have to add --all-match or the command will match commits with either. Others: --commiter: …. Limiting Log Output
  • 22.  Gitk is basically a visual git log tool, and it accepts nearly all the filtering options that git log does. If you type gitk on the command line in your project: Gitk accept nearly all filtering git log options! See logs visually!
  • 23.  One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. $ git commit --amend $ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend Changing Your Last Commit
  • 24. # Changes to be committed:  # (use "git reset HEAD <file>..." to unstage) #  # modified: README.txt  # modified: benchmarks.rb  git reset HEAD benchmarks.rb Unstaging a staged file
  • 25. # Changes not staged for commit: # (use "git add <file>..." to update what will be committed)  # (use "git checkout -- <file>..." to discard changes in working directory)  # # modified: benchmarks.rb #         $ git checkout -- benchmarks.rb $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README.txt Discard the changes
  • 26.  Anything that is committed in Git can almost always be recovered. Even commits that were on branches that were deleted or commits that were overwritten with an --amend commit can be recovered.  Anything you lose that was never committed is likely never to be seen again. YOU Should Understand this
  • 27.  To see which remote servers you have configured, you can run the git remote command. It lists the shortnames of each remote handle you’ve specified. $ git remote origin $ git remote -v origin git://github.com/schacon/ticgit.git (fetch) origin git://github.com/s…/ticgit.git (push) Showing Your Remotes
  • 28. $ git remote add pb git://github.com/paulboone/ticgit.git shortname $ git remote -v origin git://github.com/schacon/ticgit.git pb git://github.com/paulboone/ticgit.git $git remote add [shortname] [url] Adding remote repositories
  • 29. $ git fetch [remote-name] Goes to the server and get any new work, but doesn’t merge anything, you have to do it manually! If you have a branch set up to track a remote branch, you can use the git pull command to automatically fetch and then merge a remote branch into your current branch. $git pull [remote-name] Fetching and pulling from remotes
  • 30. $git push [remote-name] [branch-name] $ git push origin master This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime. If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected. You’ll have to pull down their work first and incorporate it into yours before you’ll be allowed to push. Push to the server
  • 31. $ git remote show origin • remote origin URL: git://github.com/schacon/ticgit.git Remote branch merged with 'git pull' while on branch master master Tracked remote branches master ticgit Inspecting a remote
  • 32. $ git remote rename pb paul $ git remote origin Paul $ git remote rm paul $ git remote origin Removing and Renaming Remotes