what is git?
Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people.
Commit to a Local Repository
In this Article, you will see How to:
1. View file status using git status .
2. Stage content using git add .
3. Commit content using git commit .
4. View the commit history using git log .
1: View file status using git status .
- . In a command line, navigate to your project directory and execute git status . You should see the message "Nothing to commit".
- Create an empty file named index.html in the project directory using touch index.html . This is the first file in your working tree
- . Execute git status . You should see that Git notices the index.html file and identifies it as untracked.
2: Stage content using git add .
- 1. Add index.html to the staging area using git add index.html .
- 2. Execute git status again. You should see that Git adds index.html under "Changes to be committed".
3: Commit content using git commit .
- 1. Execute git commit -m "add index.html" to create a commit. The -m option adds a commit message.
4: View the commit history using git log .
- 1. Execute git log . You should see your commit details, including your commit message.
- 2. Execute git log --oneline . A concise version of the history is displayed.