Visual Git actions from IntelliJ

Hi, my experience with version control includes CVS, SVN and more recently with Git. What I used always depended on the company and their preferences. Below I am outlining the developer stories I have encountered most and used so far with Git using IntelliJ and sometimes a terminal.

This is not a tutorial on how to use Git or a good/bad route but a personal guideline which I would like to improve in time.

Until then, these are my developer stories with Git:

  1. Create a new local branch

Often I need to create a new local feature branch to implement a specific task that would later be pushed remote. Below are screenshots of what steps I made to accomplish this.

From IntelliJ:

Navigate menu to find branches
Click “New Branch”
Write the name of the new branch
This is how it looks after the branch was created

From Terminal:

git checkout -b mylocalbranch
Switched to a new branch ‘mylocalbranch’

2. Push local branch to remote

There will come a time when you have to push the local branch to remote. First commit all changes, then add the remote (if you haven’t already) to which you want to push the code.

From IntelliJ:

Navigate to VCS->Git
List of current remotes. Here you can add more if needed
Log after creating the local branch and before pushing it to remote
Push changes to remote
After pushing local branch and the local changes

From Terminal:

git add *
git commit -m "First commit for demo."
git remote add origin https://{...}.git
git push -u origin master

3. Rebase

I want to Rebase my new branch on top of master branch so that my colleagues can have my latest modifications. It could be a big project with a lot of teams working in parallel or/and part of the “code conduct and practices” inside the company. First, make sure you commit all your changes.

Some teams might like Merging others like Rebasing. I personally like to use Rebase more. I consider that a linear history is easier to follow. For more technical details checkout out this nice Atlassian documentation.

From IntelliJ:

Checkout your feature branch, then from right bottom corner pick what branch to rebase onto, in my case it would be master. I want to take all my commits from feature branch and place them on top of master branch.

Log after rebase

Push the changes, because you will be in branch “master” and have commits from the feature branch.

Push latest commits

4. Merge remote branch into feature branch

Let’s presume I worked on your feature branch and now I am behind some commits from a “master” branch and I want to have the latest modifications. I cannot do a rebase (policy) then merge is my friend.

Checkout the feature branch in case you haven’t already. Choose what branch to merge like below and then commit the changes.

From IntelliJ:

Choose what branch you want to merge into current one
Log after merge
Push the merge changes

5. ‘Reset current branch to here’

Choose from Version Control a commit that you want to reset the project to. One scenario can be that maybe the last commits introduced a new bug and you cannot figure out what is wrong, then you can reset the branch to the point in history where you want.

Another scenario can be that you fetched all the commits from remote and you don’t want to Git->Pull (either you don’t like this, or you have some local modifications that you don’t want to stash or delete or the company is against this), you can reset the current branch there.

Next, choose how to reset. I usually use mixed. Choosing Hard will not keep any local changes and will reset to the exact commit.

If you didn’t choose Hard, then you will be left with the modified code to commit and after push to remote.

6. Update your forked branch in GitHub from the master branch

Let’s presume you want to participate in a cool Open Source project in GitHub. You fork the project first and after some time you might want to update your fork from main project.

This was a tricky one for me, but very happy I found this article on GitHub blog. for terminal commands.

From IntelliJ:

a) Add Upstream Remote in VCS>Git>Remotes…, meaning the URL from the repository you previously forked.

b) Fetch from upstream: VCS>Git>Fetch

c) Pull from upstream/master: VCS>Git>Pull

d) Or rebase your fork: VCS>Git>VCS Operations Popup

An important rule I hoped I’ve learned is to commit fast and often. Far too many times I lost my work because I didn’t commit it even locally. Don’t do like me :)

Git is a powerful tool and it can seem daunting at the beginning but in time it will become an amazing useful tool and easy to use. I am still learning and happy to do so.





Technical Software Consultant/Co-founder @ Solid Coders

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to get stock data for many symbols by using python

Fastrack your Homogeneous Database Migration for PostgreSQL to Cloud SQL(PostgreSQL)

Deploying a Group Chat App on a Serverless Architecture -Part 1 | Backend

Using Azure Functions Premium to process sales orders

Get started with Apache Spark and TensorFlow on Azure Databricks

My Final “TASC”

Integrating Relation Database Service (RDS) with WordPress Server on AWS

Remotely configuring the KeepTruckin Electronic Logging Device

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Technical Software Consultant/Co-founder @ Solid Coders

More from Medium

Understanding Git Branching

The minimum every developer must know about CORS

An overview of Git, including what it is and how to use it.

My journey as a Software Developer.