Dhananjay Patel Logo
  1. Home
  2. / Blog
  3. / Git
  4. / Lessons
  5. / 1

Prev

Next

Three stage architecture

+----------+ +---------+ +---------------+
|working | | staging | | git directory |
|directory | | area | | (repository) |
+----------+ +---------+ +---------------+
| | |
|---------stage files------->| |
| | |
| |--------commit-------->|
| | |
| |
|<---------------checkout the project----------------|
| |

File Status Lifecycle

+---------+ +----------+ +--------+ +------+
|untracked| |unmodified| |modified| |staged|
+---------+ +----------+ +--------+ +------+
|------add file------>| | |
|<----remove file-----| | |
| | | |
| |-----edit file---->| |
| | |----stage file---->|
| | |
| |<---------------commit-----------------|

Basic Git command

Terminal window
git remote-v
#origin git@github.com:CodingJury/astro-website.git (fetch)
#origin git@github.com:CodingJury/astro-website.git (push)
git status #displays the state of the working directory and the staging area
git branch #list the local branches
git branch -a #list all branches (remote as well as local)
git fetch --prune #fetch all remote branch refs
#and delete remote refs that are no longer in use
git checkout
git checkout -b <new_branch_name> <existing_branch_name> #Create checkout from the existing branch to work on feature
git checkout -p
git add .
git add --all
git add -p
git diff
git diff 'fileName'
git diff -p
git diff -p 'fileName'
git diff --staged
git commit -m "COMMIT MESSAGE"
git commit --amend
git commit --amend --no-edit
git push -u origin main
git pull
git log
git log --stat
git log --oneline
git log -p
git stash
git stash save "message"
git stash list
git stash show
git stash show -p
git stash apply
git stash apply {n}
git stash drop {N}
git stash clear

Prev

Next