ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Git for beginners
Git for beginners
?
¨C
¨C


¨C
¨C

¨C

¨C
Git for beginners
¡ú git config --global user.name "Your Name¡°
¡ú git config --global user.email "your_email@whatever.com"
¡ú git config --global core.autocrlf input
¡ú git config --global core.safecrlf true



¡ú git config --global core.autocrlf true
¡ú git config --global core.safecrlf true
Git for beginners
¡ú mkdir lerepo
¡ú cd lerepo
¡ú git init
Initialized emtpy Git repository /somedir/lerepo/.git/
¡ú echo ¡°oh hai¡± > hai.txt
¡ú git add hai.txt
¡ú git commit ¨Cm ¡°first commit¡±
[master (root-commit) 8970fa6] first commit
1 file changed, 1 insertion(+)
create mode 100644 hai.txt
¡ú ls -l
total 2
-rw-r--r-- 1 admin          None 7 Oct    1 10:23 hai.txt
-rwxr-xr-x 1 Administrators None 47 Oct   1 10:57 script.js


¡ú git add hai.txt script.js
¡ú git commit ¨Cm ¡°index all the files¡±
[master (root-commit) 8d018aa] index all the files
 2 files changed, 4 insertions(+)
 create mode 100644 hai.txt
 create mode 100644 script.js
¡ú git add hai.txt
¡ú git commit ¨Cm ¡°updated hai.txt¡±
[master (root-commit) 8970fa6] first commit
1 file changed, 1 insertion(+)
create mode 100644 hai.txt
Git for beginners
¡ú git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       hai.txt
nothing added to commit but untracked files present (use "git add" to
track)
¡ú git status -sb
# On branch master
nothing to commit (working directory clean)
Git for beginners
¡ú git status -sb
## Initial commit on master
?? hai.txt



          ?
          ?
          ?
          ?                   ?
Git for beginners
¡ú git log --pretty=oneline
56230b1 updated hai.txt (Vinh Nguyen, 33 seconds ago)
8d018aa index all the files (Vinh Nguyen, 13 minutes ago)
Git for beginners
¡ú git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
Git for beginners
git@github.com:yourname/your-repo-name.git




¡ú git remote add hub git@github.com:yourname/your-repo-name.git



¡ú git remote ¨Cv
hub git@github.com:yourname/your-repo-name.git (fetch)
hub git@github.com:yourname/your-repo-name.git (push)
Git for beginners
¡ú git status
# On branch master
nothing to commit (working directory clean)

                               ?
Git for beginners
Git for beginners
¡ú git cat-file ¨Cp HEAD
tree 56230b16f2e04c1a385008f78ad761152fdf0480
parent 8d018aa81664cf7caad20a3ab7bcd6d03354a18b
author Vinh Nguyen <name@mail.com> 1349065326 +0100
committer Vinh Nguyen <name@mail.com> 1349065326 +0100

updated hai.txt


?
?

?


?
?                                                        ?
¡ú git log --pretty=oneline
56230b1 updated hai.txt (Vinh Nguyen, 33 seconds ago)
8d018aa index all the files (Vinh Nguyen, 13 minutes ago)
56230b1 8d018aa



tree 56230b16f2e04c1a385008f78ad761152fdf0480
parent 8d018aa81664cf7caad20a3ab7bcd6d03354a18b
author Vinh Nguyen <name@mail.com> 1349065326 +0100
committer Vinh Nguyen <name@mail.com> 1349065326 +0100

updated hai.txt




       56230b1                                           8d018aa
Git for beginners
¡ú git push ¨Cf hub master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 594 bytes, done.
Total 7 (delta 0), reused 0 (delta 0)
To git@github.com/yourname/your-repo-name.git
+ c80efd2¡­40807b2 master -> master(force update)
Git for beginners
Git for beginners
# BASIC COMMAND ¡­
## note: command with slash ¡®/¡¯ in between can be optionally chosen, eg:
-s/-b, you can choose either ¨Cs or ¨Cb
¡ú git init # to initialize a git repo
¡­ hardcore hacking ¡­
¡ú git status ¨Cs/¨Cb/-sb # show file added to staging area, files with
changes, untracked files
¡ú git log hai.txt # show recent commits on hai.txt
¡ú git add ./¨CA/[file/files] # adding file(s) to index
¡ú git commit ¨Cm ¡°commit message¡± # message of a commit
### working remotely
¡ú git remote add/delete [remote.name] [git.url] # adding/deleting remote
¡ú git push [remote.name] [branch.name] # update the [remote] with your
commit from [branch.name]
¡ú git pull # fetch changes from remote and merge into current branch
¡ú git fetch [remote.name] # update the remote-tracking branch for
[remote.name] (default is origin)
# EVEN MORE COMMAND ¡­
## note: HEAD === most recent commit on your working branch. As I said
before, default is master.
¡ú git add [dir] # add all files in [dir] directory
        ¡ú git add .
### add all files under current directory, untracked file included
¡ú git rm [file1] [files2] ¡­ [fileN] # remove n files from the project
¡ú git reset HEAD [file] # remove specified file from next commit
### branching
¡ú git checkout ¨Cb [branch.name] # create a new branch and switch to it
¡ú git branch ¨Cd [branch.name] # delete a branch
¡ú git rev-parse HEAD # show me SHA of last commit
¡ú git cat-file ¨Ct HEAD # what type of last commit in current working
branch
¡ú git cat-file ¨Cp HEAD # all your last commit¡¯s information belong to
us ;)
¡ú git clone # clone a repo
Git for beginners
# Add colors to your         # Highlight whitespace in    # Add aliases to your
~/.gitconfig file:           diffs [color]                ~/.gitconfig file:
[color]                        ui = true                  [alias]
  ui = auto                                                 st = status
                             [color "diff"]                 ci = commit
[color "branch"]               whitespace = red reverse     br = branch
  current = yellow reverse                                  co = checkout
  local = yellow             [core]                         df = diff
  remote = green               whitespace=fix,-indent-      dc = diff --cached
                             with-non-tab,trailing-         lg = log -p
                             space,cr-at-eol
[color "diff"]                                              ls = ls-files
  meta = yellow bold                                        lol = log --graph --
                             # Show files ignored by git: decorate --pretty=oneline --
  frag = magenta bold
                             ign = ls-files -o -i --      abbrev-commit
  old = red bold             exclude-standard
  new = green bold
                                                            lola = log --graph --
                                                          decorate --pretty=oneline --
[color "status"]
                                                          abbrev-commit --all
  added = yellow
  changed = green
  untracked = cyan
Git for beginners
Git for beginners
Git for beginners
Git for beginners
Git for beginners
Git for beginners
¡ú git help [command]
Git for beginners
Ad

Recommended

List command linux fidora
List command linux fidora
Jinyuan Loh
?
Basics of unix
Basics of unix
Deepak Singhal
?
Terminal linux commands_ Fedora based
Terminal linux commands_ Fedora based
Navin Thapa
?
Clojure + MongoDB on Heroku
Clojure + MongoDB on Heroku
Naoyuki Kakuda
?
Unix commands in etl testing
Unix commands in etl testing
Garuda Trainings
?
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
?
Map Reduce ?ÈëéT¾Ž£ºÊ˽M¤ß¤ÎÀí½â¤È¥¢¥ë¥´¥ê¥º¥à¥Ç¥¶¥¤¥ó?
Map Reduce ?ÈëéT¾Ž£ºÊ˽M¤ß¤ÎÀí½â¤È¥¢¥ë¥´¥ê¥º¥à¥Ç¥¶¥¤¥ó?
Takahiro Inoue
?
Improving go-git performance
Improving go-git performance
source{d}
?
Mysql 4.0 casual
Mysql 4.0 casual
Masahiro Nagano
?
Ordered Record Collection
Ordered Record Collection
Hadoop User Group
?
Backup and-recovery2
Backup and-recovery2
Command Prompt., Inc
?
Practical pig
Practical pig
trihug
?
Basic commands
Basic commands
anamichintu
?
Unix Basics For Testers
Unix Basics For Testers
nitin lakhanpal
?
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce API
Tom Croucher
?
Introduction to linux day-3
Introduction to linux day-3
Gourav Varma
?
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
?
Linux-Fu for PHP Developers
Linux-Fu for PHP Developers
Lorna Mitchell
?
Codigos
Codigos
Brian Joseff
?
Linux command line cheatsheet
Linux command line cheatsheet
We Ihaveapc
?
Linux cheat-sheet
Linux cheat-sheet
Craig Cannon
?
Apache Hadoop for System Administrators
Apache Hadoop for System Administrators
Allen Wittenauer
?
40 basic linux command
40 basic linux command
Teja Bheemanapally
?
Gitosis on Mac OS X Server
Gitosis on Mac OS X Server
Yasuhiro Asaka
?
Introducci¨®n a git y GitHub
Introducci¨®n a git y GitHub
Lucas Videla
?
GIT - GOOD PRACTICES
GIT - GOOD PRACTICES
Rodolfo Spalenza
?
git internals
git internals
Dennis Byrne
?
Git Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
Raja Soundaramourty
?
Git
Git
Parag Gupta
?
Git For Beginer
Git For Beginer
Trung Huynh
?

More Related Content

What's hot (15)

Mysql 4.0 casual
Mysql 4.0 casual
Masahiro Nagano
?
Ordered Record Collection
Ordered Record Collection
Hadoop User Group
?
Backup and-recovery2
Backup and-recovery2
Command Prompt., Inc
?
Practical pig
Practical pig
trihug
?
Basic commands
Basic commands
anamichintu
?
Unix Basics For Testers
Unix Basics For Testers
nitin lakhanpal
?
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce API
Tom Croucher
?
Introduction to linux day-3
Introduction to linux day-3
Gourav Varma
?
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
?
Linux-Fu for PHP Developers
Linux-Fu for PHP Developers
Lorna Mitchell
?
Codigos
Codigos
Brian Joseff
?
Linux command line cheatsheet
Linux command line cheatsheet
We Ihaveapc
?
Linux cheat-sheet
Linux cheat-sheet
Craig Cannon
?
Apache Hadoop for System Administrators
Apache Hadoop for System Administrators
Allen Wittenauer
?
40 basic linux command
40 basic linux command
Teja Bheemanapally
?
Practical pig
Practical pig
trihug
?
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce API
Tom Croucher
?
Introduction to linux day-3
Introduction to linux day-3
Gourav Varma
?
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
?
Linux-Fu for PHP Developers
Linux-Fu for PHP Developers
Lorna Mitchell
?
Linux command line cheatsheet
Linux command line cheatsheet
We Ihaveapc
?
Apache Hadoop for System Administrators
Apache Hadoop for System Administrators
Allen Wittenauer
?

Similar to Git for beginners (20)

Gitosis on Mac OS X Server
Gitosis on Mac OS X Server
Yasuhiro Asaka
?
Introducci¨®n a git y GitHub
Introducci¨®n a git y GitHub
Lucas Videla
?
GIT - GOOD PRACTICES
GIT - GOOD PRACTICES
Rodolfo Spalenza
?
git internals
git internals
Dennis Byrne
?
Git Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
Raja Soundaramourty
?
Git
Git
Parag Gupta
?
Git For Beginer
Git For Beginer
Trung Huynh
?
Git for beginner
Git for beginner
Trung Huynh
?
Git and github 101
Git and github 101
Senthilkumar Gopal
?
Sac¨¢ndole jugo a git
Sac¨¢ndole jugo a git
Berny Cantos
?
Learning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
?
In Git we trust, by Carlos Guzman
In Git we trust, by Carlos Guzman
Carlos Guzm¨¢n
?
Git Basic
Git Basic
Luke Luo
?
Git walkthrough
Git walkthrough
Mahmoud Said
?
Loading...git
Loading...git
Rafael Garc¨ªa
?
Get Good With Git
Get Good With Git
Hoffman Lab
?
Git real slides
Git real slides
Lucas Couto
?
Git_real_slides
Git_real_slides
Khanh NL-bantoilatoi
?
Git Tutorial Yang Yang
Git Tutorial Yang Yang
Yang Yang
?
Git
Git
jimmythrasher
?
Ad

Recently uploaded (20)

10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
?
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
?
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
?
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
?
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
?
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
?
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
?
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
?
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
?
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
?
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
?
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
?
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
?
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
?
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
?
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
?
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
?
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
?
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
?
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
?
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
?
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
?
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
?
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
?
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
?
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
?
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
?
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
?
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
?
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
?
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
?
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
?
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
?
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
?
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
?
Ad

Git for beginners

  • 3. ?
  • 6. ¡ú git config --global user.name "Your Name¡° ¡ú git config --global user.email "your_email@whatever.com"
  • 7. ¡ú git config --global core.autocrlf input ¡ú git config --global core.safecrlf true ¡ú git config --global core.autocrlf true ¡ú git config --global core.safecrlf true
  • 9. ¡ú mkdir lerepo ¡ú cd lerepo ¡ú git init Initialized emtpy Git repository /somedir/lerepo/.git/ ¡ú echo ¡°oh hai¡± > hai.txt ¡ú git add hai.txt ¡ú git commit ¨Cm ¡°first commit¡± [master (root-commit) 8970fa6] first commit 1 file changed, 1 insertion(+) create mode 100644 hai.txt
  • 10. ¡ú ls -l total 2 -rw-r--r-- 1 admin None 7 Oct 1 10:23 hai.txt -rwxr-xr-x 1 Administrators None 47 Oct 1 10:57 script.js ¡ú git add hai.txt script.js ¡ú git commit ¨Cm ¡°index all the files¡± [master (root-commit) 8d018aa] index all the files 2 files changed, 4 insertions(+) create mode 100644 hai.txt create mode 100644 script.js
  • 11. ¡ú git add hai.txt ¡ú git commit ¨Cm ¡°updated hai.txt¡± [master (root-commit) 8970fa6] first commit 1 file changed, 1 insertion(+) create mode 100644 hai.txt
  • 13. ¡ú git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # hai.txt nothing added to commit but untracked files present (use "git add" to track)
  • 14. ¡ú git status -sb # On branch master nothing to commit (working directory clean)
  • 16. ¡ú git status -sb ## Initial commit on master ?? hai.txt ? ? ? ? ?
  • 18. ¡ú git log --pretty=oneline 56230b1 updated hai.txt (Vinh Nguyen, 33 seconds ago) 8d018aa index all the files (Vinh Nguyen, 13 minutes ago)
  • 20. ¡ú git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
  • 22. git@github.com:yourname/your-repo-name.git ¡ú git remote add hub git@github.com:yourname/your-repo-name.git ¡ú git remote ¨Cv hub git@github.com:yourname/your-repo-name.git (fetch) hub git@github.com:yourname/your-repo-name.git (push)
  • 24. ¡ú git status # On branch master nothing to commit (working directory clean) ?
  • 27. ¡ú git cat-file ¨Cp HEAD tree 56230b16f2e04c1a385008f78ad761152fdf0480 parent 8d018aa81664cf7caad20a3ab7bcd6d03354a18b author Vinh Nguyen <name@mail.com> 1349065326 +0100 committer Vinh Nguyen <name@mail.com> 1349065326 +0100 updated hai.txt ? ? ? ? ? ? ¡ú git log --pretty=oneline 56230b1 updated hai.txt (Vinh Nguyen, 33 seconds ago) 8d018aa index all the files (Vinh Nguyen, 13 minutes ago)
  • 28. 56230b1 8d018aa tree 56230b16f2e04c1a385008f78ad761152fdf0480 parent 8d018aa81664cf7caad20a3ab7bcd6d03354a18b author Vinh Nguyen <name@mail.com> 1349065326 +0100 committer Vinh Nguyen <name@mail.com> 1349065326 +0100 updated hai.txt 56230b1 8d018aa
  • 30. ¡ú git push ¨Cf hub master Counting objects: 7, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (7/7), 594 bytes, done. Total 7 (delta 0), reused 0 (delta 0) To git@github.com/yourname/your-repo-name.git + c80efd2¡­40807b2 master -> master(force update)
  • 33. # BASIC COMMAND ¡­ ## note: command with slash ¡®/¡¯ in between can be optionally chosen, eg: -s/-b, you can choose either ¨Cs or ¨Cb ¡ú git init # to initialize a git repo ¡­ hardcore hacking ¡­ ¡ú git status ¨Cs/¨Cb/-sb # show file added to staging area, files with changes, untracked files ¡ú git log hai.txt # show recent commits on hai.txt ¡ú git add ./¨CA/[file/files] # adding file(s) to index ¡ú git commit ¨Cm ¡°commit message¡± # message of a commit ### working remotely ¡ú git remote add/delete [remote.name] [git.url] # adding/deleting remote ¡ú git push [remote.name] [branch.name] # update the [remote] with your commit from [branch.name] ¡ú git pull # fetch changes from remote and merge into current branch ¡ú git fetch [remote.name] # update the remote-tracking branch for [remote.name] (default is origin)
  • 34. # EVEN MORE COMMAND ¡­ ## note: HEAD === most recent commit on your working branch. As I said before, default is master. ¡ú git add [dir] # add all files in [dir] directory ¡ú git add . ### add all files under current directory, untracked file included ¡ú git rm [file1] [files2] ¡­ [fileN] # remove n files from the project ¡ú git reset HEAD [file] # remove specified file from next commit ### branching ¡ú git checkout ¨Cb [branch.name] # create a new branch and switch to it ¡ú git branch ¨Cd [branch.name] # delete a branch ¡ú git rev-parse HEAD # show me SHA of last commit ¡ú git cat-file ¨Ct HEAD # what type of last commit in current working branch ¡ú git cat-file ¨Cp HEAD # all your last commit¡¯s information belong to us ;) ¡ú git clone # clone a repo
  • 36. # Add colors to your # Highlight whitespace in # Add aliases to your ~/.gitconfig file: diffs [color] ~/.gitconfig file: [color] ui = true [alias] ui = auto st = status [color "diff"] ci = commit [color "branch"] whitespace = red reverse br = branch current = yellow reverse co = checkout local = yellow [core] df = diff remote = green whitespace=fix,-indent- dc = diff --cached with-non-tab,trailing- lg = log -p space,cr-at-eol [color "diff"] ls = ls-files meta = yellow bold lol = log --graph -- # Show files ignored by git: decorate --pretty=oneline -- frag = magenta bold ign = ls-files -o -i -- abbrev-commit old = red bold exclude-standard new = green bold lola = log --graph -- decorate --pretty=oneline -- [color "status"] abbrev-commit --all added = yellow changed = green untracked = cyan
  • 43. ¡ú git help [command]