Git and GitHub
GitHub is a web-based hosting service for version control using Git.
It is a central repository. It provides access control and several collaboration features such as bug tracking, feature requests, and task management.
Public repository is free but maintaining a private repository is a paid service.
Open-source developers created GitLab to make everything free. Bitbucket is also an alternative to GitHub.
Connect to Central Repo (GitHub):-
First, you need to create your GitHub account and a repository in your account.
Go to the GitHub site [https://github.com] and create an account
Create a "New Repository"


Login to your EC2 Instance and create your working directory
mkdir new-git ; cd new-git ; git status ;Clone the Repository
git clonehttps://github.com/<Name>/firstrepo-public;
cd firstrepo-publicCreate a new file, add it to staging, and do the commit
echo "New File..." > firstrepo.txt
git add firstrepo.txt
git commit -m "First Commit"
Check which remote repository is connected:
git remote -vGenerate a token to give permissions for the remote user for the GitHub Repo.
Else, you will be prompted for a username and password, will the pull and push requests.

Login to your Github > Settings > Developer Settings > Personal access tokens > Tokens(classic) > Generate new token > Generate new token(classic) > Assign a
Token Note - choose the Expiration period and select what permissions you want to give to this particular token. -> Generate Token -> Copy the token
Use, the token and the Repo URL, that we created earlier
git remote set-url originhttps://ghp=L0i4HLonwhnKash2KzcnXGb2K3We1qy@github.com/kcG/firstrepo-publici.e
https://<Personal-access-tokens-Key>@github.com/<Git-Username>/<Repo-URL>https://ghp_49pQuYE7-PerSonap-Tokken-Key@github.com/ketangharateG/react_django_demo_appVerify the origin will get changed
git remote -v
Now, push your local repo to the central repo.
[Your local repo data will be copied to the central repo]git push origin masterNow, To pull from the remote repo.
[Download from central repo to your local repo]git pull origin masterIf pulling branches other than master, change the branch name.
Create a new file on the Central repo and try to pull them.

- Collaborate between Local and Remote Repository using
git pullandgit push
Pull the commits from the Remote Repositorygit pull origin mastergit push origin master
ORIGIN: Git indicates that a remote repository can be added and identified with a keyword known as origin.
Git enables moving files from the Local Repository to the Remote Repository using
HTTPS
OR
SSHCreate a Repository in GitHub using SSH
Ensure the local Repois ready
Create SSH Key using (ssh-keygen)
Configure GitHub with SSH Public Key
Create a Github Repo
Push from Local Repo to GitHub
Create a Repository in GitHub using HTTPS
Go to GitHub and login
Create a New Repository
Follow GitHub Instructions
git remote -v
git remote add origin https://github.com/<Repo-Name>
- When you will create Repo you will be shown the cmd line instructions.
- You can also copy the URL from GitHub > Repo > Code <>section
git remote -v
git push origin master
Comments
Join the discussionNo comments yet. Be the first to comment.