Git Exercises

Ques.3- Modify the `README.md` file and add some new content

Ans- To modify the `README.md` file and add new content 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. Open the `README.md` file in a text editor and make the desired changes or add new content.

4. Save the changes in the text editor.

5. Run the command `git status` again to see that the `README.md` file is listed as modified.

6. Add the modified `README.md` file to the staging area using the command `git add README.md`.

7. Run the command `git status` once more to verify that the `README.md` file is in the staging area (it should appear in green).

8. Commit the changes with a descriptive message using the command `git commit -m "Modify README.md and add new content"`. Replace "Modify README.md and add new content" with your own descriptive message.

9. After running the commit command, Git will display the commit hash and information about the commit.


Remember to push your changes to the remote repository using `git push` to make the hanges available to others.


To stage 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 stage, you can stage all changes by running the command `git add .` (to stage all modified files) or `git add <file>` (to stage a specific file). Replace `<file>` with the actual filename.

4. After running the `git add` command, the modified files will be staged and ready for the commit.

5. You can run the command `git status` again to see that the files you want to commit are now in the staging area (they should appear in green).

6. Once the changes are staged, you can proceed to commit them using the `git commit` command.


Staging changes allows you to carefully select which modifications you want to include in the next commit. It gives you control over what changes are part of the commit and helps maintain a clear and organized commit history.



About the Author



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





 PreviousNext