This article teaches you what is working directory and how to commit.
J. GIT Components
The 4 main components of GIT.
First of all, let’s see the working Directory.
1. Create a project directory git-learning using cmd, git bash or terminal.
2. Go to the git-learning directory.
3. Create a file index.html in git-learning.
4. See what are the files in git-learning
5. Open the folder in VS Code, if we need to control our project folder using git
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.
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
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”
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.