Now you will practice how to add files to the repo how to edit it & how to delete a file.
Create a new file in users. The file name can be your roll_number.text
Example:
touch users/99071a0508.txt
Creates a file under users directory.
git status
Shows the local Git repo status.
(base) kp@kuru:~/codelabs$ git status
On branch main
Your branch is up to date with 'origin/main'.Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: 99071a0508.txtno changes added to commit (use "git add" and/or "git commit -a")
git add users/99071a0508.txt
git status
Adds the file to git envelope(packet) that can be pushed to cloud
(base) kp@kuru:~/codelabs$ git status
On branch main
Your branch is up to date with 'origin/main'.Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: 99071a0508.txt
git commit -a -m "Krishna Prasad user file"
Gives a label to the change envelope for files added so far.
[main 778905c] Krishna Prasad user file
1 file changed, 1 insertion(+), 0 deletions(-)
git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)nothing to commit, working tree clean
git push
Step 1: Open the File
Use your preferred text editor to edit the file. For example:
users/your_rollnumber.txt
Step 2: Save and Stage the Changes
After making the changes, save the file and add it to the Git staging area:
git add users/your_rollnumber.txt
Note you can add as many files as you wish.
Step 3: Commit the Changes and push
Commit the updated file with a relevant message:
git commit -m "Updated content in my file #1"
rm users/example_file.txt
git rm users/example_file.txt
git commit -m "Removed my file from the users directory"
git push