How To use GitHub?
We don't know how to Push or Pull to/from a github repository.
So lets learn today.
\======>PULL Code from Github:
Suppose you have a public repository.
In the top-right corner there is option "<>Code"
Then there are 3 options:
-HTTPS
-SSH
-Github CLI
Go to HTTPS -> Copy the URL while launching lab & on launch of the lab give yes to clone github repository and paste the URL. Then Proceed.
Now all the code inside the repository is copied as it is into the lab. All Codes can be accessed and executed.
\======>PUSH Code into Github:
How to push code from lab into the repository:
Go to Profile -> Your Repositories -> Create new public/private repository -> You will recieve a list of commands as:
echo "# justfortrial" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin <URL>
git push -u origin main
These commands you have to run in the command prompt of lab.
If you don't want to add README file the can do: "git add ."
Sometimes, when adding remote origin, error pops out that remote origin already exists. For that you can use command:
--------> git remote remove origin
Now, you can add remote origin. This error pops because by default one origin is added into the lab.
The last command pushes everything into main branch of origin.
When you run the last command, the github will ask for sign-in for authorizing, after you allow it give you a code which you must copy and click on continue. Then it will ask for permission to open external website. Click "Open". New window will open, now paste the code and continue. After that, it will ask to authorize with visual studio code, click on "Authorize". Then it may/not ask for password of github account so enter password if asked.
\======>PULL Code from Github:
Open the lab.
Go to github and get the URL ending with ".git" (in HTTPS tab)
in the command-line in lab, write:
git clone <URL>
Automatically all the code, only if public URL, is added into the lab.
Subscribe to my newsletter
Read articles from Karan Thakkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by