Understanding Git
- To understand Git, we need to understand 5 areas of git
- Lets start from folder level
- Create an empty directory
mkdir learning
- Lets make this folder intelligent with Version Control,
cd learning
git init
- Lets start our journey with three areas of git
- Working Tree/Working Directory
- Staging Area
- Local Repository
- BY adding git init we have made learning folder as repository
- If you want physical locations according to above example
- Now make some changes and execute the following commands
touch readme.txt
- Now the
git status
command will describe the changes to the developer - The changes are in working tree and we need to move the changes from working tree to staging, This operation is called as add (We are adding changes)
git add --help
# add all the changes in current directory
git add .
git status
- Now we need to move the changes from staging to local repository, bcoz local repository has all the feature which we need in Version control System. This operation is as commit and to perform this operation, git should know your username and your email id
git config --global user.name "qtdevops"
git config --global user.email "qtdevops@gmail.com"
- Now lets add changes from staging area to local repository
git commit -m "This is my first commit"
git status
git log
-
Now let this developer add one more change, add some text to existing file and create a new file
-
Add these changes to staging area and then local repo
-
Terms:
- Untracked: Is a file which was never part of local-repository. Newly added files are generally untracked
- Modified: Making changes to existing file in local repository
- Color Significance:
- Red => Working Tree
- Green => Added to staging area
-
Workflow:
-
Dont Remember git commands use cheatsheets Refer Here