git

Get the latest release tag from a Github repository

Sometimes I needed to programmatically get the tag name of the latest release from a GitHub repository. It’s often useful for automating tasks through scripts or for creating installer CLIs. The GitHub public API provides this information, so you’ll get it using your shell. Define the repository in the REPO environment variable. This way it will be easier for you to try other repositories later. REPO='kubernetes/kubernetes' Now use curl to issue a request to the GitHub REST API.

Undo last Git commit

Have you ever made changes that you regretted? Git relies heavily on its history, and you may feel that your latest commit only contributes to creating a big mess in it for the other developers of the project. If you already did a commit and now you want to delete it, don’t worry, there is a solution for that. You can remove the last commit from the git history with the command below:

Replacing author for multiple Git commits

Some time ago I was taking the course Master Microservices with Spring Boot and Spring Cloud but I had to leave it because these days I was getting very busy. Yesterday, after three months, I returned back and after pushing changes to GitLab repo, I noticed that changes were made with my GitHub email address instead of using the GitLab one. Last commit could be easily changed with the command below: