- FORK it to your own GitHub account
- COPY the link from your new repo on GitHub
- CLONE it to your local machine. Example:
git clone https://github.com/[YourUsername]/[name-of-git-repository]
If you want to update your forked repository from my parent repository when I add or change things to mine in the future, there are instructions below this section.
It will go much easier if you don't ever change the code in main. Instead, do the following:
- From
main, use the commandgit checkout -b new-branch-nameto create your own branch for practicing (example:functions-practice). - Practice as much as you'd like in your new branch, making commits as you add code.
- When you are ready to work on something different in another new branch, use the command
git checkout mainto return tomainand then you can repeat the two steps above.
Set the upstream link:
- On your local machine, make sure you are in the correct directory in the terminal.
- Use the command
git remote add upstream https://github.com/CodeWithCarrie/[name-of-git-repository]
You now have a direct link to my original repo!
Use the command git remote -v to verify that you have linked to both origin (your forked repo) and upstream (my original repo)
Update your repo anytime I make changes in the future:
- On your local machine, make sure you are in the correct directory in the terminal.
- If you have any uncommitted changes, stage and commit them.
- Make sure you are in the branch you wish to update (e.g.
main) - Use the command
git fetch upstreamso your local repo has knowledge of changes I made in my repo - Use the command
git rebase upstream/mainto sync your repo
Check to see which branches you already have:
- You can use the command
git branchanytime to see what local branches you have - The command
git branch -rwill show you branches that exist on GitHub (after you've fetched that knowledge)