Tag: Git

How to Add SSH Key to GitLab?

How to Add SSH Key to GitLab?

It’s very important to add an SSH key to GitLab to work on a remote project what is hosted on GitLab. Let see how we can do that โ€“
We working on a Mac to set up this key โ€“
1. Go to your terminal and write the command below โ€“

ssh-keygen -t rsa -C "[email protected]"

Press Enter (to make a file with the default name)
Type ‘y’ (to overwrite
Press Enter (to skip passphrase)
2. To see the generated key type :

cat ~/.ssh/id_rsa.pub

Copy the key and paste it to your GitLab profile.

Done ๐Ÿ™‚

Now start pull / push / clone etc. commands.

Common Git Commands

Common Git Commands

Go to the directory you want to initiate Gitย and then follow the commands:

  1. Initiate the git:
    git init
  2. Remove Git if you have initiated in a wrong place ( Be aware if there is another git in the subdirectory):
    rm -rf .git
  3. To add all the files(including subdirectory) to the staging step:
    git add .
    Or,
    git add -A
  4. Git branch โ€“
    a. Create a new one from the current branch and Checkout to the new branch:
    git checkout -b newBranch
    b. Delete a branch branch:
    git branch -d branchName
    
  5. Merge master to development branch โ€“
    1. //pull the latest changes of current development branch if any 
    git pull (current development branch)

    2. //switch to master branch
    git checkout master

    3. //pull all the changes if any
    git pull

    4. //Now merge development into master
    git merge develop

    5. //push the master branch
    git push origin master