Git: Revert commit and see what was change in a commit

Revert is usually a safe operation as it create a new commit.

git revert <SHA>

Before you revert a commit, you might want to check what was change in the commit as you might want to keep changes that were lumped in the commit:

git show SHA

If you made a commit in the wrong branch:

Go to proper branch and run: 

git cherry-pick <HASH> 

go to old branch, run: 

git revert <HASH>

In case of error see: https://blog.seobytes.eu/development/git-returns-is-a-merge-but-no-m-option-was-given/

Create remote repository from local (bitbucket/github)

Command to use:

Set up bitbucket ssh access.

Open a terminal in local directory and run:

git init
git checkout -b feature-branch

Create repository in Bitbucket and get the ssh url by clicking on the clone button.

In yout terminal run:

git remote add origin git@bitbucket.org:nicolashoquet/arcade.git

In case “origin” already exists, you can rename origin by running this command:

git remote rename origin https-origin

or use another name for origin (e.g. ssh-origin).

Set git ssh access for github or bitbucket

https://docs.github.com/en/github/getting-started-with-github/setting-your-username-in-git

Open a terminal

cd in the folder were you want to clone the repo:

$ cd directory/you/clone
$ git init
$ git config user.name “Your-Username” #can be different from your github username
$ git config user.email “your.email@example.com
$ ssh-keygen -t rsa -C “your.email@example.com

Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username.ssh/id_rsa

Copy the content of the id_rsa.pub in your Github settings in your profile.

Set Github local authentication to be able to clone and push:

http://kbroman.org/github_tutorial/pages/first_time.html

git stash

Save your current work on branch and return to a clean branch.

The following is copied from: https://git-scm.com/docs/git-stash

git-stash – Stash the changes in a dirty working directory away

SYNOPSIS

git stash list [<log-options>]
git stash show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
	     [-u|--include-untracked] [-a|--all] [-m|--message <message>]
	     [--pathspec-from-file=<file> [--pathspec-file-nul]]
	     [--] [<pathspec>…​]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>

DESCRIPTION

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and restored (potentially on top of a different commit) with git stash apply. Calling git stash without any arguments is equivalent to git stash push. A stash is by default listed as “WIP on branchname …​”, but you can give a more descriptive message on the command line when you create one.

The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it, stash@{2.hours.ago} is also possible). Stashes may also be referenced by specifying just the stash index (e.g. the integer n is equivalent to stash@{n}).

Uninstall docker from Ubuntu

If you installed docker with snap:

simple uninstall:

sudo snap remove docker

and to disable automatic snapshot:

sudo snap remove --purge docker

If after reinstalling docker you have the following error:

bash: /snap/bin/docker: No such file or directory

you need to run

hash docker

and

hash docker-compose

Installation instruction:

https://docs.docker.com/engine/install/ubuntu/

Note that if you installed an old version with snap, you should follow the instruction provided in this article.

https://docs.docker.com/compose/install/

Log integer in beanshell and get integer from variables

Issue:

log.info() returns the following error in JMeter beanshell:

 Error in method invocation: Method info( int ) not found in class'org.apache.logging.slf4j.Log4jLogger'

Solution:

The error message indicates you are trying to pass an integer in the log.info() method. To prevent this issue, convert the integer to the type String using:

String SomeString = new Integer.toString(somInteger);

Similarly, numerals are passed as strings in JMeter variables, to make arithmetic operation on them, you’ll need to convert them to integer using:

int someInteger = new Integer.parseInt(someString);

Example use:

vars.put("test", new Integer(i).toString());

yarn : ERROR: There are no scenarios; must have at least one. On Ubuntu

Issue: The following error is displayed when running yarn in the same directory as the package.json file:

00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.

Solution:

this is the wrong yarn ubuntu install cmdtest. You need to remove it and install the correct yarn package.

Run:

sudo apt remove cmdtest
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list 
sudo apt update 
sudo apt install yarn

How to solve merge conflict in git cli?

$  git merge TEST_2
 Auto-merging test.txt
 CONFLICT (content): Merge conflict in test.txt
 Automatic merge failed; fix conflicts and then commit the result.
$git mergetool --tool-help
'git mergetool --tool=' may be set to one of the following:
araxis
vimdiff
vimdiff2
vimdiff3
...
$ git mergetool --tool=vimdiff