Sunday, January 31, 2021

Git create feature branch

 1. checkout the branch from which you want to create feature branch

git checkout  <existing branch>

2. create feature branch and checkout feature branch in one step

git checkout  -b  <feature branch name>

3. change the code in feature branch and commit to remote repository.

git  add  -A

git commit  -m  "update"

git  push origin  <feature branch name>

New feature branch committed to remote.

Labels: ,

How https works?

There are many possible ways when you are accessing any https hosted resource :

1.  When you request from browser for any https websites  site like 'https://google.com', the process will be as follows:



 

public key :  The key which used to encrypt the data.

private key : Every public has corresponding private key which used to decrypt the data encrypted by corresponding public key.

CA (certificate authority) : CA are who signed the certificate,  they sign the certificate using their        public key. Browsers generally comes standard CA certificates like Google CA certificates.


2. There is a case when you are developing your own web app and you want to host on https web server.

In this scenario we need to have self signed certificate because in this case google or other CA will not go to sign your certificate.

And when any application try to communicate with your application they need to have your certificate inside their trust store.


Labels: , , ,

Thursday, January 21, 2021

Git credential storage

Git credential storage

We can use git config to enable git credential storage in git

Run the following command

git config --global credential.helper store

After this when we do pull or push it will ask for username / password and when you enter it, it will store the credential inside flat file .git-credentials.

Next time when you perform pull or push it will not ask for credentials.

Labels: , , ,

Friday, January 15, 2021

Rename remote and local git branch

We can rename any remote and local git branch  using following steps:

1. Checkout the branch that you want to rename

git checkout <existing branch name>

2. Rename the above checked out branch in your local
git branch -m <new branch name>

3. Push the branch with new changed name

git push origin -u <new branch name>

4. Remotely branch with old name also exist, which you can delete
git push origin --delete <old branch name>

Labels: ,

Friday, January 8, 2021

Compare two objects with possible 'null' value - java.util.Objects

 Java 7 provided the new class called 'Objects'. This class provides a null safe method to compare

two objects.

java.util.Objects

boolean equals(Object a,Object b) 

- if both object are null , it will return true

- if one object is null,  false will return

- otherwise equality comparison based on equals() method


example :

String s1 = null;

String s2 = "one";

if you apply s1.equals(s2);

Then in this case  if s1 is null like here, it will give you nullpointer exception

So for safe comparison we can use.

Objects.equals(s1,s2);

This will return false in our case.

Labels: ,