Pushing Existing Code to GitHub using HTTPS
Prerequisites:
- Git must be installed on your local machine.
- A GitHub account.
- An existing project on your local machine.
Run below command
git push https://github.com/AzureDevops-demoproject/Git_demo.git master
It will ask for personal token to connect to github
Create personal token from github
Go to profile –> Setting –> developer setting
Developer setting –>personal access tokens–> Tokens /(classic)–> generate new token
Now we can go and check the repository
File push to github repository
How to clone from github to local machine
git clone https://github.com/AzureDevops-demoproject/Git_demo.git
Next create ,modify the code, git add, commit follow below steps
78 touch file3
79 git status
80 git config user.name :"RAj"
81 git config user.email "usus@gmail.com"
82 git add
83 git add --all
84 git status
85 git commit -m"adding other user"
86 git status
87 git log
88 git push origin master
now push back to github (remote location)
git push origin master (if you done clone and can use origin instead of long url)
or
git push https://github.com/AzureDevops-demoproject/Git_demo.git master
or
check repository now
Now other want to pull it
use below command
Use below so can use origin in future instead of long url
git remote add origin https://github.com/AzureDevops-demoproject/Git_demo.git
Now use
git pull origin master
Now, Sync the local repository as remote repository
Now using SSH
First need to generate SSH key using below
ssh-keygen
Copy public key in github
where to copy in github –> go to profile –> setting–> SSH and GPC key –> new ssh key — add public and save it
Use ssh link same way as we doing for https:
git@github.com:AzureDevops-demoproject/Git_demo.git