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
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 branchesgit 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 checkoutgit checkout -b <new_branch_name> <existing_branch_name> #Create checkout from the existing branch to work on featuregit checkout -p
git add .git add --allgit add -p
git diffgit diff 'fileName'git diff -pgit diff -p 'fileName'git diff --staged
git commit -m "COMMIT MESSAGE"git commit --amendgit commit --amend --no-edit
git push -u origin main
git pull
git loggit log --statgit log --onelinegit log -p
git stashgit stash save "message"git stash listgit stash showgit stash show -pgit stash applygit stash apply {n}git stash drop {N}git stash clear