This article teaches you what is working directory and how to commit.
J. GIT Components
The 4 main components of GIT.
-
Working Directory
-
Staging Area
-
Committed History
-
Development Branches
First of all, let’s see the working Directory.
1. Create a project directory git-learning using cmd, git bash or terminal.
mkdir git-learning
2. Go to the git-learning directory.
cd git-learning
3. Create a file index.html in git-learning.
touch index.html
4. See what are the files in git-learning
ls
5. Open the folder in VS Code, if we need to control our project folder using git
git init
Note: This command changes the current directory to the git repository. If we are not in the git-learning project folder, first go to the git-learning project folder. After init the project.
cd git-learning
git init
6. Create a sample project in Vs code and check the status of the project.
There are some commands you can see on this git bash. Let's see them one by one.
- On branch master: branch is master.
- No commits yet: No actions made in a git repository.
- Untracked files: Our creating file index.html isn’t in the git repository.
7. So, how to add those untracked files to the git repository.
git add index.html
git status
If you add any data in your file index.html you must add a file in the git repository everytime. For an example,
Consider adding ul data in your file after adding the index.html file in the git repository.
Now you have checked the status of your project again.
Changes are not staged for commit. So you have to add the file again in the git repository.
Now changes to be committed.
8. How to record or commit our data in a git repository.
git commit -m “Initial Commit”
git status
Now no changes in the working directory and git repository.
I hope you understand what is working directory and how to commit. In later chapters, we will discuss the staging area.
0 Comments