Git-Notes

Source code management (SCM)

Git Global Config List

git config --list

Git States

  1. Working Directory
  2. Staging Area
  3. Commit

git init - To initialize a git repository
git Status - To see if any files have been updated
git clone - To clone a remote repository
git log - To see the commits done by the user
git log --oneline - To see short logs
git log --stat -To see detailed log
git log --patch -To see much more detailed info with the lines added/deleted you can also search for using sha eg :/19a297c
git show shaFromOneline - eg: git show b25dd4a to show a specific change if it shows device null no deletion has been made

when we use git add filename or git add . we are moving a file from working directory to staging area
git commit is used for making the commit git commit -m "what has been changed" helps to add comment directly, without the -m it will open a text editor.
git diff -To see the changes in a file
git restore --staged filename - To pull a file from staging area back to working directory

.gitignore file is used to ignore files/folder

* is used as a wildcard match and # is used for comments

git tag

There are two types of tags

  1. Annotated tag -a
  2. Light weight tag (No detail)

git tag used for versioning the commits
git tag -a 19a297c -To tag a particular commit
just using git tag will tag the most recent commit
The -a in git tag means annotated tag
git tag -d V1.0 to delete a particular tag

git branch

git branch is used while adding new functionality fixing bugs without effecting the main branch
git branch - It shows all branches
git branch branchName - To create a branch
git switch branchName - To switch to a branch
git switch -c branchName - To create and switch to that branch
git tag -d V1.0 to delete a particular tag