cd to Git
clone respository if necessary to local machine and then cd
git clone <repo-location>
The origin
remote is pre-set for you by GitHub to point to your forked repo.
Let's add another remote called upstream
- this will be your main repo (the repo that you forked from).
The command to do that is git remote add upstream <repo-location>
Our plan is to have our master
branch of the forked repo mirror the master
branch of the main repo while each feature we work on gets it's own branch.
Let's say we wanted to add words to the words.txt
file. In order to do that, let's create a branch called word-addition
. This is done with the command git checkout -b <branch-name>
.
This creates a new branch and automatically switches you into it. git push origin word-addition
git commit -am "Description Here
to commit new changes
git push origin word-addition
to push to the newly created branch
Remember that upstream
remote that we created?
Well, it's time to bring it out to play.
We first fetch the changes from upstream
and then rebase our repo with upstream's master
.
git fetch upstream
check to make sure you are in master
branch using git branch
to check and git checkout <branch-name>
to switch.
git rebase upstream/master
check progress with git status
commit changes
git push origin master
find new files as well as staging modified content and removing files that are no longer in the working tree
git add . -A
git commit -m "removed some files"
git push origin master
navigagte to local git repository
git fetch upstream
git checkout master
git merge upstream master
git push origin master