mobile menu trigger, icon

Category: Git

Git is one of the most popular version control systems in the world. It helps you to keep track of changes to your project.

Learn Git from the very basic

Learn Git from the very basic

You can think of this post as an online course to learn Git for free. I will walk you through very basic steps such as definition, installation, command line interface, etc, to the advanced level. I included video instructions where it’s applicable & necessary. Also, I explained each & every subject/topic from the ground up and provided practical examples. Therefore if you still have any questions, you can ask me. What you’ll get: After you go through this course, you’ll be able to use Git in your everyday life. This will make your life as a developer much easier than […]

Read More →

How to git push after rebase?

Push after rebase

In this post, you’ll know how to perform a successful git push after rebase. Pushing changes to the remote origin is nothing new. But there are some situations where the push may be rejected. Or it can override someone else’s progress. After you rebase, the commit history changes. So you need to push with the “–force” flag. If you encounter a “git push rejected” error after rebasing a feature branch, here are some steps you can follow to fix it. Double-check your changes After rebasing a feature branch, ensure you have resolved conflicts and staged the changes using the git […]

Read More →

When should you use git rebase?

When to use git rebase

Git rebase allows you to integrate changes from one branch into another. You can apply commits from the source branch to the target branch. But when actually you should use git rebase? Use git rebase when you want to maintain a clean commit history, incorporate changes from a parent branch, resolve conflicts in a controlled manner, and collaborate on shared branches in a team setting. However, don’t make a habit of using git rebase every time especially when you have other sophisticated ways to solve an issue. It becomes very handy when you need to change a certain commit message. […]

Read More →

Git add all – how to stage all changes on git?

stage files in git

To add all files & folders on git, use the following command: git add -A This command will stage all the changes for the next commit. There are some other similar commands on git that I will discuss later in this post. Git is one of the most popular version control systems around the globe. It keeps track of the changes to your project. You can learn more about Git, why it is used, why people like it so much, etc in this post. Troubleshoot — Commands before git add -A (all) If you see a fatal error such as […]

Read More →

How to remove file from Git?

How to remove files from git?

In this post, you’ll see how to remove file from git in different contexts. If you committed a file by mistake and pushed it to the remote origin, there are commands to delete the file. Also, if you want to keep a file locally on your machine but delete it only from the remote origin, there is a command for it as well. Last but not least, you also have a way to ignore the deleted file from the future commit & push. Let’s explore them one by one. How to delete files from Git To delete a file locally, […]

Read More →

Git switch branches: How to checkout the git branch?

Git switch branches

When you work on different git branches, you may need to switch between branches in your command line (terminal). In Git’s terminology, switching branches refers to the “git checkout” command. Anyways, to switch or change a git branch type the following command and hit enter: git checkout branch_name_here Replace the branch_name_here with the actual branch name you want to switch to. The above command will allow you to jump/navigate from one branch to another. How to switch from the master branch to another branch? Let’s say you want to switch from the master branch to another branch named “about-page.” To […]

Read More →

How to undo the last Git commit?

How to undo the last git commit

There are a couple of options for undoing the git commit. Also, there are two scenarios where you may need to undo the last git commit. Such as undo commit that you did not push yet (locally) and the last commit that you already pushed to the remote origin. I will show you all these options. Undoing git commit that has not been pushed yet Type the following command and hit enter to undo the last commit: git reset HEAD~1 The above command will reset the branch to the previous commit. It will also keep the changes you made last […]

Read More →

How to undo the git add -A command?

Undo git add -A

If you accidentally ran the git add -a and if you want to undo this command, follow the step below: First of all, check the status by git status This will show you the list of the files that are staged. It’s not mandatory but good to check. So you can compare the end of undoing the git add command. Second, type the following command and hit enter: git reset . This will unstage all files or remove all the files from the staging area. That’s it! See how to remove files from Git. Now if you run the git […]

Read More →

How to change the git commit message?

How to change git commit message

This post will show you how to change the git commit message. And this commit could be the last one or a specific number of commit such as the 5th or 6th or 9th commit message. You’ll find all sorts of documents to change the commit message. Such as every step with exact commands, screenshots, and video instructions. How to change the last git commit message? If you wrote a wrong message in the last commit, you can change it very easily as you normally run other git commands. To change the last commit message, type the following command & […]

Read More →

How to remove or unstage a file from Git commit?

Remove file from git commit

This post will show you how to remove or unstage a file from the git commit. Note that it’s different than removing a file from git. Anyways, if you make a commit & even if you pushed the changes to the remote origin, this is still possible to remove a file from the commit and the remote git repository. Let’s see how you can do it. How to remove a file from git commit? I will walk you through the step-by-step process but I suggest you take a backup of your repository or download a zip. This is just for […]

Read More →