Establishing your trading style

What type of trader are you? Swing, Scalper, Position Trader? Whatever classification you label yourself, the importance of sticking with a style is going to determine whether you are successful or…

Smartphone

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




Git Undo Changes

There are many scenarios where you want to remove your changes from GIT. In this article, we will cover them all.

The clean command cleans your working directory by recursively removing files that are not under version control, starting from your working directory.

Git provides you an option to do a dry run to know what files will be removed by this command.

Once you are cognizant of the files that will be removed, you can use git clean -f to force delete the files.

If you want to remove untracked directories, you have to just add -d to the command.

The second scenario, is when you have done some changes and by mistake you have staged them. Now, you want to remove those staged changes and go back to the version that matches with the remote. git reset -hardwill simply replace everything across the board without checking.

Reset command will reset all the files in the working directory including the ones which are correct and which you misplaced. Git provides you option to reset individual files with the checkout command.

If you want to remove the file from staged but not lose the changes that you made, then you need to use the command git reset HEAD . This command will remove your files from staging area, but the changes will still be available in your local working area.

The third scenario is when you have committed your changes but you have not pushed them yet. In this case, you have to use the reset command again.

In case, you have pushed your unwanted commit, you need to run a revert command, if you need to preserve history. To do this, you need to know your previous correct commit’s SHA code. The SHA code can be found, with the help of git log command. Let’s consider your SHA code is 123456, then the revert command will be

Alternatively, if you don’t need to preserve history, then you can use the reset command.

Once you perform the git reset, you need to force push the local changes to remote using

If you liked this article, click the 👏 so other people will see it here on Medium.

Add a comment

Related posts:

There is no free lunch.. or vacation!

If there is one thing that is clear from life as an adult, it is- there is no free lunch! Every action you take comes with a trade-off and a pro-con baggage you automatically sign up for. Of course…

How Botsheets Makes Conversational Commerce Easy

With Black Friday just days away, Christmas shopping right after that, and support for Instagram chatbots just weeks away, there is good reason to be excited about conversational commerce. It’s not…

Anger and bots on Twitter are not affecting vaccinations in France

This story is part of my newsletter DaNumbers. Click here to know more (and to subscribe — for free). BRUSSELS — Is the media overestimating the campaign against the Green Pass? A sentiment analysis…