☰
-
Php 95
-
Java 94
-
Javascript 37
-
Regex 18
-
Git 17
-
Security 16
-
Docker 07
-
Python 58
-
Machine Learning 14
-
Book Highlights
Git Basics States
On every commit, Git takes a picture of files GIT stores everything in his DB using hashes git add . git commit -m "First commit"
States
p06 Git has three main states that your files can reside in.
#!/bin/sh
: "Git has three main states that your files can reside in:
Working tree | File changed but not committed it to database yet
Staging area | File marked as modified to go into your next commit
Repository | Committed file is stored in your DB
The history of the project is on the local disk
GIT stores everything in his database using hashes
"
alias gs="git status | sed 's/^/\t/' ; echo"
alias gsp="git status --porcelain | sed 's/^/\t/' ; echo"
touch myfile.tmp
echo "touch"
echo "Working Tree:"; gsp
git add .
echo "git add"
echo "Staging Area:"; gsp
git commit -qm "m"
echo "git commit"
echo "Repository:"; gs
git rm -q myfile.tmp
echo "git rm"
echo "Staging Area:"; gsp
git commit -qm "m"
echo "git commit"
echo "Repository:"; gs

touch
Working Tree:
?? main/basics/states/myfile.tmp
git add
Staging Area:
A main/basics/states/myfile.tmp
git commit
Repository:
On branch main
nothing to commit, working tree clean
git rm
Staging Area:
D main/basics/states/myfile.tmp
git commit
Repository:
On branch main
nothing to commit, working tree clean
➥ Questions
Last update: 7 days ago