Ans- To commit changes using Git, follow these steps:
1. Open your terminal or command prompt and navigate to the root directory of your Git repository.
2. Check the status of your repository by running the command `git status`. This will show you the modified files and any untracked files.
3. If you have modified files that you want to commit, ensure that they are staged for the commit. You can stage changes using the `git add` command. For example, to stage all modified files, run `git add .` or to stage a specific file, run `git add <file>`.
4. After staging the changes, you are ready to commit them. Use the command `git commit -m "Your commit message"` to create a new commit. Replace "Your commit message" with a concise and meaningful message that describes the changes you made.
For example:
$ git commit -m "Update README file"
This creates a commit with the message "Update README file".
5. After running the commit command, Git will display the commit hash and information about the commit. It will also indicate the number of files changed and the number of insertions and deletions.
Congratulations! You have successfully committed your changes using Git.
Remember to push your commits to the remote repository using `git push` to make the changes available to others.
Here's an example of the commands:
$ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.html
modified: styles.css
$ git commit -m "Update index.html and styles.css"
[main 21bc624] Update index.html and styles.css
2 files changed, 20 insertions(+), 8 deletions(-)
In this example, the `index.html` and `styles.css` files are modified and staged for the commit. We run `git commit -m "Update index.html and styles.css"` to commit the changes with a descriptive message. Git then provides information about the commit, including the number of files changed, insertions, and deletions.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc