Friday 18 February 2022

Merging branches in Git and Push files to branches using SSH Key


#at terminal

mkdir demo-merge

cd demo-merge/


echo "hello DevOps" > index.html

git add -A

git init

git add -A

git commit -m "First Commit"

git branch

#change branch name to main

git branch -m main

git branch

git remote add origin <HTTPS URL>

git remote -v

git push -u origin main

#Now do the setting for Push files using SSH key


git remote remove origin

git remote -v

#ssh push and pull


#add password if necessary



#share .pub key with git-hub⇒Settings⇒SSH and GPG keys⇒New SSH key




#Copy /home/ubuntu/.ssh/ key and paste

Add SSH key

confirm access

git remote add origin <SSH URL>   

git remote -v

git push -u origin main

#yes ask for the first time

#verify the push remote

#merging example

git checkout -b JIRA

echo "adding new feature" >

git add *

git commit -m "done JIRA"

git push -u origin JIRA

git branch




ls  index.html

git checkout develop

Switched to branch 'develop'

Your branch is up to date with 'origin/develop'.

ls  index.html

#to merge JIRA branch to develop switch to develop branch

git merge JIRA

Updating b50ca2a..4a62f5e

Fast-forward | 1 +

 1 file changed, 1 insertion(+)

 create mode 100644

ls  index.html

git push -u origin develop

#verify the push in Github remote, develop branch

No comments:

Post a Comment