This guide will provide the usage of the βgit checkoutβ command along with the β–theirsβ option for multiple project files.
How to βgit checkout –theirsβ for Multiple Files?
To check out for multiple files, follow the provided steps:
- Go to the Git repository.
- List the existing content of the repository.
- Select multiple files and update them one by one without pushing them to the staging index.
- Show the status of the working repository.
- Switch to the root directory.
- Execute the βgit checkout –theirs <repo-name/*>β command.
- Navigate to the target repository and view the status.
Step 1: Navigate to Git Repository
At first, execute the βcdβ command along with the desired repository path:
Step 2: List Existing Content
Then, display the list of current repository content by running the βlsβ command:
Here, we have selected three text files which are highlighted below:
Step 3: Modify Selected File
Next, modify the βfile.txtβ file through the βechoβ command:
Step 4: Update Selected File
Execute the βechoβ command and add the changes into the specified file:
Step 5: Edit File
Similarly, edit another file with the help of the provided command:
Step 6: Check Status
Now, execute the below-given command to check the status of the current working Git repository:
As you can see, all modified files exist in the Git working directory:
Step 7: Checkout With β–theirsβ
Now, switch to the root directory and use the βgit checkoutβ command:
In the above-stated command, the β–theirsβ option signifies that the current branch is being rebased. The βtest1/β is the name of the Git local repository, which contains modified untracked files and an asterisk β*β symbol after the slash β/β indicates all files.
According to the below-given output, the paths of all unstaged files are updated:
Step 8: Check Git Status
Lastly, move to the Git repository and view its status by running the βgit status .β command:
It can be seen that all unmerged files are added to the staging area:
Thatβs all! We have demonstrated the βgit checkout –theirsβ process for more than one file.
Conclusion
To check out for multiple files, first, move to the Git repository and list the existing content of the repository. Then, choose multiple files and update them one by one without adding to the index. Next, check the status of the current working repository and switch to the root directory. Finally, execute the βgit checkout –theirs <repo-name/*>β command. Lastly, navigate to the target repository and view the status. This guide briefly illustrated the βgit checkoutβ command with the β–theirsβ option for multiple files.