Blog Post 2

In my first observation, I went around 1 pm on Wednesday. I decided to come back early this time and hope to see a change. Its now Friday of the same week but 8 am. I picked this time because I know…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




The Most Useful Git Shortcuts

Git is surely one of the most valuable tools in any developer’s toolkit. I was using SourceTree a lot, but recently switched to command line interface and I don’t think I will go back.

Now I’m using Oh my ZSH, which comes with some awesome shortcuts for git. In this article, I will describe some of the most useful ones for me.

Productivity is the key

You should commit often! Git is an awesome safety net and a tool, which allows multiple developers to work on the same project. However, you need to commit often, if you want to make the best out of it. These two commands enable you to commit and push the files, which are modified and stashed. The biggest gotcha of this command, is that it won’t commit new files, unless you stash them with git add.

Typos, broken alignments, wrong comments, or just silly mistakes happen to the best of us. These two commands enables you to commit the files, which are modified and stashed. The previous commit will be amended and its commit message reused. The gotcha here is that we’re changing the commit history, because we are not creating the new commit, but changing the latest one. Therefore, we need to force push this commit. Git push force-with-lease option lets you force push your local changes, while making sure that you won’t overwrite someone else’s work. Force with lease option verifies that the remote latest change, is the same as the local one. In other words, no one has committed on top of your latest commit and therefore it is safe to force push your fix.

So, you’re working for a couple of days on this new awesome feature. If there are more developers working on the same project, it’s only natural that your feature branch diverges from master. Not only will these commands fetch the latest changes, but also delete/prune the branches which have been removed on the remote. This keeps your local repository nice and clean. Note, that if there are some conflicts, the merge will fail. It will also list all the files in which you need to manually resolve conflicts. Once you’re done, you can add them and run git commit.

And my secret weapon is an alias.

This bad boy will remove all your local branches, except for the current one and master.

Happy Source Versioning!

Add a comment

Related posts:

Top 10 SEO tips for WordPress websites

Here are 10 simple WordPress SEO tips to get noticed by the world wide web and stand apart from the crowd: To get a high-class performance for your Wordpress website, you need to improve the volume…

Les bases de Sololearn.com

Sololearn.com est une organisation ayant pour objectif de permettre aux gens d’apprendre, gratuitement, l’univers du code et de l’informatique à l’aide de leur site web et de leur application…

6 Eco Coffee cups with Style

More than 125 million people around the world depend on coffee, so the Fairtrade Foundation explains. This results in average of 1.6 cups per person. When you sum that up these are a lot of cups and…