A git "repo" is a workspace which tracks and manages files and directories with in a git initialized project.
- To initialize a git within a project
git init
- It is used to initialize a git setup within a project to track changes.
- This is the first basic git command required to start git.
- Can be used only once in a project at the begining.
Note: about .git directory
- After executing git init, you'll probably notice there is one .git named hidden directory get automatically created by git.
- This directory holds all the history of your project after installation.
- It is made hidden because you can't delete that accidentally.
- If deleted manually then all the history will be deleted.Then you need to do git init again.
Warning: DO NOT INITIALIZE A REPO INSIDE A REPO
- Before initializing a repository must check whether that repo is already initialized or not.
- you can use git status command to verify whether you're in git repo or not.
- To check status
git status
- It is used to check status of changes made in git repo
- Either the changes will be untracked or tracked if added to staging area.
- To add file to staging area
or to add everything use the given commands below
git add file1.txt
git add -A git add .
- It is used to add files to staging area.
- staging area means where files are ready to be commited.
- To commit the changes
git commit -m "commit message"
- It is used to commit the staged changes.
- commit message should represent the commit changes
- To log the previous commits
or to log commit messages in one line
git log
git log --oneline
- It is used to see previous commits made
- one line argument is really helpful to display log messages in one line