github Flashcards
What is cloning?
Copying the repository from GitHub.com to your local machine.
Command to clone a repo.
git clone
Proper use of git clone
Create a new folder & cd into it. Then use git clone with the repo’s url.
What is a remote?
A url where a repo pushed up to. Basically just the url where the repo exists online.
Command to view a list of any existing remotes in your repo.
git remote or git remote -v (verbose for more info)
Command to add a new remote.
git remote add (name is usually origin)
Command to push code to github.
git push
Command to push a local branch to a remote branch with a different name.
git push origin name1:name2
Command to rename master to main.
git branch -M main
What is a remote tracking branch?
The last time you communicated with a particular remote repo, this is a pointer that points to the most recent changes on that repo’s master branch. So it’s basically a bookmark which shows the most recent change on the main branch from the origin.
Command to see where remote tracking branch currently is.
git branch -r
Command to see what your project looked like when you cloned it from github.
git checkout origin/main
Command to get the online repo up to date with your local machine.
git push origin main
When you clone a repo, by default it is connected to origin/master. If you want to switch to another branch you use the ________ command.
git checkout /origin/branchname
Command to create a new local branch from the remote branch of the same name.
git switch (This will set the branch up to track the remote branch origin/remoteBranchName. So it basically creates a new branch and automatically connects it to main in the same way that the original branch is)