In continuation to the previous tutorial about making changes in the local repository and pushing them to the remote repository, this post starts from where we left. If you somehow landed on this post without reading the git push tutorial, it is highly recommended to give it a read first. Catching up, the changes were pushed successfully on to the GitHub account of the user and it is quite certain that the user would like to verify those changes as the next step. We will surely do that. Along with it, we will explore a few more options which the git push command offers. To summarise, this tutorial will cover:
- Verifying the changes on GitHub repository.
- Different options in Git Push.
Verifying Committed Changes on GitHub
To verify the changes on GitHub, the user needs to navigate to the GitHub repository on which they performed the change in the git push tutorial. For this, first of all, sign in to the GitHub account.
Navigate to the repository page through the side panel available for quick navigation.
2. You can notice two things in the GitHub repository page as shown in the image:
- Time Of Commit (Latest Commit 285f559 2 days ago): The latest commit is shown as two days ago which shows that the commit the user pushed the changes two days ago. Along with the time, the hash value is also present for the commit (285f559). If you would have gone through the Git Log tutorial, you will be familiar with it and would notice that this is the shorter version of the actual hash value. Match this with the hash value you got in the Git Bash while pushing the changes.
- Commit Message (Clone Web Page Modified): This is the commit message with which we committed the changes that we pushed. You would get your own message on this page. To know more about the commit messages and how they should be written, this link would help you.
Although this is enough to confirm that the changes have been synchronised with the GitHub account, for more information, the user can also go through the commits tab on the same repository page.
Commits tab will show the entire history of commits that have happened on this repository.
Each commit block will contain a lot of information and links that can be accessed to attain more information about the repository and that particular commit. Let’s explore one block (top most) to know about it.
The different important things to notice have been marked in steps in the above image:
- Commit Message: The headline of the block will contain the commit message that the user used while committing the changes in the Git. Since I used “Clone Web Page Modified”, I am getting a similar output here.
- Copy Hash Value to Clipboard: This icon represents the action of copying something to the clipboard. In GitHub, pressing this icon will copy the hash code of the commit on to the clipboard. Since everything in Git is found and saved by the hash value, it becomes a very integral part of the overall Git process.
- Hash Code of the Commit: This is the hash code of the commit of which this block is about. This is the compressed version of the actual hash code. The same code will be copied when you press the copy to clipboard icon but in original and expanded form.
- Check History: This button will help the user to check the history of the repository till that point of time when this commit was performed. So, if we click this button on any previous commit blocks, this commit will not be shown since it happened after that commit. The user will be able to see the state of the repository only till that point of time. This is why version control system term was used while explaining Git.
Just to have a look, press the hash code (3rd option) and see where are we navigated:
This page will show the changes that were performed during the commit i.e. the before and after changes. The pink line in the above image shows the line that has been deleted. It can be seen by (-) sign beside the line. Similarly, the lines added have a (+) sign.
The user can also check the URL of this web page. It would be similar to github.com/repository_name/hash_code_value in the generalised form. This is why the hash code is so important. If the user has a hash code, navigation to any commit on GitHub is very easy. Next, select the history button (4th option) and see where GitHub will take you.
It will take the user to the repository home page when that particular commit would have happened and showing the same values of commit message and hash code etc. By this, we are assured about the changes that we have made are reflected onto the GitHub account.
Coming back to the git push, like any other command in Git, we can use options while executing the command to achieve a specific task. For example, if you want to push all the branches, you would use all option and so on. This would be our focal point of the next section i.e. options in git push command.
Options Available in Git Push command In Git
As mentioned in the last section, there are many options available in Git push command that helps us achieve certain specific tasks with just one execution. In this section, we will take you through the important and most used options in the git push command.
Prune Option in Git Push
–prune option in git push command will delete the remote branch XYZ if there does not exist any branch with the same name in the local repository.
Usage: git push –prune remote XYZ
Dry Run Option in Git Push
This option will perform and show the execution of git push command but will not send any updated to the remote repository.
Usage: git push –dry-run <remote> <local_branch>
IPV4 Option in Git Push
IPV4 option will use only ipv4 address for the complete process and will ignore the ipv6 addresses. It is useful when the project you are working somehow relates to networking or security.
Usage: git push –ipv4
IPV6 Option in Git Push
IPV6 option is similar to ipv4 option but here Git will ignore the ipv4 address and use the ipv6 address.
Usage: git push –ipv6
All Option in Git Push
All option will push all the branches and their committed changes to the remote repository.
Usage: git push –all <remote>
By this, Git push command can be exercised completely according to your use on your Git and GitHub account. I hope the usage and importance of Git push command are clear enough. We will move on to the next tutorial on Git.