After cloning a repository, you need to create a new branch named feature-update. Create the branch and switch to it. ee the Solution below. Solution: cd /home/user/projects/repo git branch feature-update git checkout feature-update Explanation: The git branch command creates a new branch, while git checkout switches to it, allowing changes to be made without affecting the main branch.
Make a file named config.txt in the cloned repository, add sample configuration details, and commit the file with the message "Add initial config". ee the Solution below.Solution: cd /home/user/projects/repo echo "server=127.0.0.1" > config.txt git add config.txt git commit -m "Add initial config" Explanation: New files must be staged with git add before committing. The git commit command saves the changes with a descriptive message.
You realize you need to modify the config.txt file to add a new configuration port=8080. Update the file and commit with the message "Add port configuration". ee the Solution below. Solution: echo "port=8080" >> config.txt git add config.txt git commit -m "Add port configuration" Explanation: Appending to a file and committing the changes ensures version control captures the updated state, allowing tracking of incremental modifications.
You need to check the history of commits in the repository. Display a concise log of the last 3 commits. ee the Solution below. Solution: git log --oneline -n 3 Explanation: git log --oneline provides a simplified view of commits, while -n 3 limits the output to the last three entries, helping analyze recent changes.
Push your changes from the feature-update branch to the remote repository. ee the Solution below. Solution: git push origin feature-update Explanation: Pushing ensures the local changes are reflected in the remote repository, allowing collaboration and backup of the branch.
You are given access to a Git repository with the URL https://github.com/example/repo.git. Clone the repository to your local machine in the directory /home/user/projects. ee the Solution below. Solution: cd /home/user/projects git clone https://github.com/example/repo.git Explanation: Cloning a repository retrieves all files, branches, and history to your local system. The git clone command initiates this process by downloading the specified repository.