Tuesday, August 29, 2023

Connect from Local Git to Github


GIT


Create a user git

chown -R git:git /home/git


su git


$ cd /home/git


$ mkdir .ssh


$ cd .ssh


$ git config --global user.name "git"


$ git config --global user.email "yashwanthsn@gmail.com"


$ git config --list


user.name=git
user.email=yashwanthsn@gmail.com


Create a repository on GITHUB: https://github.com/new
enter the details and click on create repository


Create a "automation" directory on local git

$ mkdir automation


$ cd automation


$ pwd
/home/git/automation


run git init command
Add SSH git link using git remote add origin command

git remote add origin git@github.com:yashwanthsn2020/automation.git


you can change this to https git link later using git remote set-url origin command

git remote set-url origin git@github.com:yashwanthsn2020/automation.git

Create a config file under $HOME/.ssh in local git

check on how to add SSH Keys from local Git to GITHUB repository -> Generate SSH Keys for Github GIT
Now check the branch and run git push command using git branch and git push commands
Now go to GITHUB -> https://github.com and click on automation repository

In my case the link is https://github.com/yashwanthsn2020/automation


You will be able to see the file that we pushed from local git to github