This content originally appeared on DEV Community and was authored by Abhinav Pandey
Why do I need to check out a source repository alongside my forked repository?
- It helps you to compare the source code of the forked repository with the source code of the source repository.
- It also helps you to see the changes made in the source repository.
Checking out the source repository
Step 1:
Open a Git Bash terminal.
Step 2:
Change directory to the directory where you have cloned the repository.
Step 3:
Check out the source branch.
Command syntax:
git remote add repo_name url_of_source_repository
Runnning the command will add a remote repository named "repo_name" to the local repository.
Step 4:
Fetch the source branch.
Command syntax:
git fetch repo_name master
Runnning the command will fetch the master branch from the remote repository.
Comparing the two repositories
To compare the two repositories, you can use the following command:
git diff --stat origin/master repo_name/master
The option --stat
shows the number of added, deleted, and modified lines and not the actual content of the files. Don't use --stat
if you want to see the actual content of the files.
Checking latest commits in the source repository
To see the latest commits in the source repository, you can use the following command:
git log [--oneline] [--graph] [--after=date] [--before=date] [--author=author] repo_name/master
The option --oneline
shows the commit message.
The option --graph
is used to show the commit graph.
The option --after=date
shows the commits after the date.
The option --before=date
shows the commits before the date.
The option --author=author
shows the commits made by the author.
There can be many more options to filter the commits. Check the Git log documentation for more information.
Thank you for reading! If you want to connect with me, you can find me on Twitter @abh1navv
This content originally appeared on DEV Community and was authored by Abhinav Pandey
Abhinav Pandey | Sciencx (2021-11-19T07:20:52+00:00) Git Tip: Keeping an eye on the source repository. Retrieved from https://www.scien.cx/2021/11/19/git-tip-keeping-an-eye-on-the-source-repository/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.