SlideShare a Scribd company logo
1 of 44
Download to read offline
ɪ
–
–


–
–

–

–
→ 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
→ mkdir lerepo
→ cd lerepo
→ git init
Initialized emtpy Git repository /somedir/lerepo/.git/
→ echo “oh hai” > hai.txt
→ git add hai.txt
→ git commit –m “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 –m “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 –m “updated hai.txt”
[master (root-commit) 8970fa6] first commit
1 file changed, 1 insertion(+)
create mode 100644 hai.txt
→ 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 status -sb
## Initial commit on master
?? 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)
→ git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
git@github.com:yourname/your-repo-name.git




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



→ git remote –v
hub git@github.com:yourname/your-repo-name.git (fetch)
hub git@github.com:yourname/your-repo-name.git (push)
→ git status
# On branch master
nothing to commit (working directory clean)

                               
→ git cat-file –p 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 push –f 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)
# BASIC COMMAND …
## note: command with slash ‘/’ in between can be optionally chosen, eg:
-s/-b, you can choose either –s or –b
→ git init # to initialize a git repo
… hardcore hacking …
→ git status –s/–b/-sb # show file added to staging area, files with
changes, untracked files
→ git log hai.txt # show recent commits on hai.txt
→ git add ./–A/[file/files] # adding file(s) to index
→ git commit –m “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 –b [branch.name] # create a new branch and switch to it
→ git branch –d [branch.name] # delete a branch
→ git rev-parse HEAD # show me SHA of last commit
→ git cat-file –t HEAD # what type of last commit in current working
branch
→ git cat-file –p HEAD # all your last commit’s information belong to
us ;)
→ git clone # clone a repo
# 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 help [command]
Git for beginners

More Related Content

What's hot

Practical pig
Practical pigPractical pig
Practical pigtrihug
 
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce APIUpgrading To The New Map Reduce API
Upgrading To The New Map Reduce APITom Croucher
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3Gourav Varma
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenPostgresOpen
 
Linux-Fu for PHP Developers
Linux-Fu for PHP DevelopersLinux-Fu for PHP Developers
Linux-Fu for PHP DevelopersLorna Mitchell
 
Linux command line cheatsheet
Linux command line cheatsheetLinux command line cheatsheet
Linux command line cheatsheetWe Ihaveapc
 
Apache Hadoop for System Administrators
Apache Hadoop for System AdministratorsApache Hadoop for System Administrators
Apache Hadoop for System AdministratorsAllen Wittenauer
 

What's hot (15)

Mysql 4.0 casual
Mysql 4.0 casualMysql 4.0 casual
Mysql 4.0 casual
 
Ordered Record Collection
Ordered Record CollectionOrdered Record Collection
Ordered Record Collection
 
Backup and-recovery2
Backup and-recovery2Backup and-recovery2
Backup and-recovery2
 
Practical pig
Practical pigPractical pig
Practical pig
 
Basic commands
Basic commandsBasic commands
Basic commands
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce APIUpgrading To The New Map Reduce API
Upgrading To The New Map Reduce API
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
 
Linux-Fu for PHP Developers
Linux-Fu for PHP DevelopersLinux-Fu for PHP Developers
Linux-Fu for PHP Developers
 
Codigos
CodigosCodigos
Codigos
 
Linux command line cheatsheet
Linux command line cheatsheetLinux command line cheatsheet
Linux command line cheatsheet
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Apache Hadoop for System Administrators
Apache Hadoop for System AdministratorsApache Hadoop for System Administrators
Apache Hadoop for System Administrators
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 

Similar to Git for beginners

Similar to Git for beginners (20)

Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X Server
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
GIT - GOOD PRACTICES
GIT - GOOD PRACTICESGIT - GOOD PRACTICES
GIT - GOOD PRACTICES
 
git internals
git internalsgit internals
git internals
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Git
GitGit
Git
 
Git For Beginer
Git For BeginerGit For Beginer
Git For Beginer
 
Git for beginner
Git for beginnerGit for beginner
Git for beginner
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
In Git we trust, by Carlos Guzman
In Git we trust, by Carlos GuzmanIn Git we trust, by Carlos Guzman
In Git we trust, by Carlos Guzman
 
Git Basic
Git BasicGit Basic
Git Basic
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Git_real_slides
Git_real_slidesGit_real_slides
Git_real_slides
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git Tutorial Yang Yang
Git Tutorial Yang YangGit Tutorial Yang Yang
Git Tutorial Yang Yang
 
Git
GitGit
Git
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Git for beginners

  • 1.
  • 2.
  • 3. ɪ
  • 5.
  • 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
  • 8.
  • 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 –m “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 –m “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 –m “updated hai.txt” [master (root-commit) 8970fa6] first commit 1 file changed, 1 insertion(+) create mode 100644 hai.txt
  • 12.
  • 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)
  • 15.
  • 16. → git status -sb ## Initial commit on master ?? hai.txt     
  • 17.
  • 18. → git log --pretty=oneline 56230b1 updated hai.txt (Vinh Nguyen, 33 seconds ago) 8d018aa index all the files (Vinh Nguyen, 13 minutes ago)
  • 19.
  • 20. → git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
  • 21.
  • 22. git@github.com:yourname/your-repo-name.git → git remote add hub git@github.com:yourname/your-repo-name.git → git remote –v hub git@github.com:yourname/your-repo-name.git (fetch) hub git@github.com:yourname/your-repo-name.git (push)
  • 23.
  • 24. → git status # On branch master nothing to commit (working directory clean) 
  • 25.
  • 26.
  • 27. → git cat-file –p 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
  • 29.
  • 30. → git push –f 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)
  • 31.
  • 32.
  • 33. # BASIC COMMAND … ## note: command with slash ‘/’ in between can be optionally chosen, eg: -s/-b, you can choose either –s or –b → git init # to initialize a git repo … hardcore hacking … → git status –s/–b/-sb # show file added to staging area, files with changes, untracked files → git log hai.txt # show recent commits on hai.txt → git add ./–A/[file/files] # adding file(s) to index → git commit –m “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 –b [branch.name] # create a new branch and switch to it → git branch –d [branch.name] # delete a branch → git rev-parse HEAD # show me SHA of last commit → git cat-file –t HEAD # what type of last commit in current working branch → git cat-file –p HEAD # all your last commit’s information belong to us ;) → git clone # clone a repo
  • 35.
  • 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
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43. → git help [command]