Next git commands

This article describes the next level of git commands with respect to my previous post on git.

BRANCHES IN GIT:

You may need branches when you need to have different codebases for dev, stage, prod etc.,

$ git checkout -b "newbranch"

check branch you are in with

$ git branch

then start to add files

$ git add .

Check the status of files

$ git status

Then commit to git

$ git commit

$ git push origin <newbranch>

GIT REMOTE SET URL:

You need to set remote url for your git.

$git remote set-url origin <url>

SETTING SSH KEYS FOR GIT:

If you feel not to enter your password each time you make a push you need to set SSH keys.

First, generate ssh keys in your machine

$ ssh-keygen -t rsa

Then check the keys

$ cat ~/.ssh/something.pub

Copy that output and move to Github profile settings and add SSH key in the SSH keys menu.

Then you can push changes without need to enter password each time.

 

Advertisements