Background
Let us review some of the GIT commands one will use each day.
List of Command
Command | Description | Syntax | Link |
---|---|---|---|
File Operation | |||
Add | Add a new file | git add <filename> | Link |
Remove | Remove an existing file | git rm <filename> | Link |
Rename or Move | Rename or move an existing file | git mv <filename> <folder> | Link |
Repository | |||
Clone | Clone Remote Repository to Local Repository | git clone | Link |
Commit | Commit to Local Repository | git commit | Link |
Push | Upload Local Repository to Remote Repository | git push | Link |
Pull | Download Remote Repository to Local Repository | git pull | Link |
Reset | Reset Changes made to Local Repository | git reset | Link |
Git Versioning | |||
status | Review Git Status | git status | Link |
log | Review Git Log | git log | Link |
show | Review Git Show | git show | Link |
Commands
Git – help
Syntax
git --help
Sample
git --help
Output – GUI
Git – Version
Syntax
git --version
Sample
git --version
Output
Output – GUI
Output – Text
$ git --version git version 2.29.2.windows.2
Git – add
Outline
Add file.
Syntax
git add [filename]
Sample
git dbo.kjv.sql
Git – rm
Outline
Remove file.
Syntax
git rm [filename]
Sample
git rm dbo.kjvduplicate.sql
Git – mv
Outline
Rename or move a file.
Syntax
git mv [filename] [filename] git mv [filename] [directory]
Sample
git mv dbo.kjvduplicate.sql deprecated
Git – clone
Outline
Create a local repository sourced from Remote Repository
Syntax
Syntax – Basic
git clone [remote-repository]
Sample
git clone https://github.com/DanielAdeniji/Sample
Syntax – Folder
git clone [remote-repository] [target-folder]
Sample
git clone https://github.com/DanielAdeniji/Sample sampling
Output
Output – Image
Output – Text
+ git clone https://github.com/DanielAdeniji/Sample sampling Cloning into 'sampling'... remote: Enumerating objects: 40, done. remote: Total 40 (delta 0), reused 0 (delta 0), pack-reused 40 Receiving objects: 100% (40/40), 6.17 KiB | 526.00 KiB/s, done. Resolving deltas: 100% (15/15), done.
Git – commit
Outline
Commit Changes locally.
Syntax
git commit
Sample
git commit -m "Added kjv.sql"
Git – push
Outline
Upload Local Repository to Remote Repository.
Syntax
git push
Sample
git push
Git – pull
Outline
Download Local Repository from Remote Repository.
Syntax
git pull
Sample
git pull
Git – reset
Outline
Rollback changes made to Local Repository.
Syntax
git reset
Sample
git reset
G
Git – status
Outline
Get the status of the current repository
Syntax
git status
Sample
git status
Output
Output – Image
Output – Text
$ git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: gitAdd.cmd Untracked files: (use "git add <file>..." to include in what will be committed)
Explanation
- Modified Files
- gitAdd.cmd
Git – log
Outline
Read out the log of changes
- Basic
- git log
- Filter by author
- Info
- The person who issued git add, git rm
- Syntax
- git log –author
- git log –author=<author-id>
- git log –author
- Info
- Filter By Committer
- Info
- The person who issued git commit
- Syntax
- git log –committer
- git log –committer=<committer-id>
- git log –committer
- Metadata
- Filtering ID:- Author ID, Committer ID
- IDs are case sensitive
- LarryScott and lscott are different
- Part ( Substring ) matches
- Larry will match LarryScott and LarryBrown
- IDs are case sensitive
- Filtering ID:- Author ID, Committer ID
- Info
- Filter by date
- Info
- Filter by date before and after
- Syntax
- git log –after
- git log –after=<date>
- git log –after
- Sample
- git log — after 2020-12-01
- Metadata
- date’s syntax is YYYY-MM-DD ( ISO )
- Info
Syntax
git log
Sample
Sample – Basic
git log
Sample – Filter by Author
git log --author=DanielAdeniji
Output
Output – Image
Explanation
Git Log Mode
Image
Explanation
- When you enter “git log” you are taking into a command mode
- Please enter the letter q to exit the command mode
Filter by Date – Before
Syntax
Syntax – Before
git log --before YYYY-MM-DD
Output
Filter by Date After
Syntax – Filter by Date After
git log --after YYYY-MM-DD
Sample – Filter by Date After
git log --after 2020-12-01
Output
Output – Image
List log – Single Line at a time
Syntax – oneline
git log --oneline
Sample – oneline
git log --oneline
Output
Output – Image
List log – Pretty
Syntax – pretty
git log --pretty=format:"<format>"
Sample – pretty
git log --pretty=format:"%n, %ar : %s"
Output
Output – Image
Git – Show
Outline
Shows log messages and textual differences between versions.
Syntax
git show
Sample
git show
Output
Output – Image
Explanation
Git Log Mode
Image
Explanation
- When you enter “git show” you are taking into a command mode
- Please enter the letter q to exit the command mode
[…] Git – Client – Commands Link […]