3

Git Tip: Keeping an eye on the source repository

 2 years ago
source link: https://dev.to/abh1navv/git-tip-keeping-an-eye-on-the-source-repository-3jk6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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
Enter fullscreen modeExit fullscreen mode

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 
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK