Exploring and Working with the Cloned Repository
Now that you have successfully cloned the repository, let us explore it and learn how to work with it.
Navigating to the Repository Directory
First, navigate to the cloned repository:
cd ~/project/test-repo
Viewing Repository Contents
To view the contents of the repository, use the ls
command:
ls -la
You should see the README.md file and the .git directory:
total 16
drwxr-xr-x 3 labex labex 4096 Jul 15 12:34 .
drwxr-xr-x 10 labex labex 4096 Jul 15 12:34 ..
drwxr-xr-x 8 labex labex 4096 Jul 15 12:34 .git
-rw-r--r-- 1 labex labex 16 Jul 15 12:34 README.md
Viewing the README.md File
Let us examine the content of the README.md file:
cat README.md
The file should contain:
## Test Repository
Checking the Git Status
To check the status of your repository, use the git status
command:
git status
The output should indicate that you are on the main branch and your working directory is clean:
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Viewing Commit History
To view the commit history of the repository, use the git log
command:
git log
You should see the initial commit:
commit abcdef1234567890abcdef1234567890abcdef12 (HEAD -> master, origin/master)
Author: LabEx User <[email protected]>
Date: Mon Jul 15 12:34:56 2023 +0000
Initial commit
Making Changes to the Repository
Let us make a simple change to the README.md file:
echo "This is a test repository for learning Git authentication." >> README.md
View the updated content:
cat README.md
The updated file should look like:
## Test Repository
This is a test repository for learning Git authentication.
Now you have successfully cloned a Git repository using username and password authentication, explored its contents, and made changes to a file. In a real-world scenario, you would commit and push these changes back to the remote repository, which would also require authentication.