Learn the basics of Git through an interactive workshop.
- Fork this repository to your personal Github account
- Download or
git clone
your personal fork to your local computer - Add this repo as
upstream
:git remote add upstream <repo-url>
- Review the commit log:
git log
- Review the reference log:
git reflog
- Create a new "fix" branch:
git checkout -b fix_name-spelling
- Find your name within the
team.txt
file and correct its spelling - Save your changes
- Review your Git status:
git status
- "Stage" your change to be committed:
git add team.txt
- Review your Git status:
git status
- Commit your changes:
git commit
- Push your changes to
origin
:git push origin fix_name-spelling
- PR your new branch to
upstream/main
- Main has been updated, you can no longer merge your PR
- Switch your local
main
branch:git checkout main
- Pull updates from
upstream
:git pull upstream main
- Switch back to your "fix" branch:
get checkout -
- Rebase your "fix" branch with
main
:git rebase main
- Your
rebase
will halt and ask you to fix the conflict - Before you move on, familiarize yourself with the CLI instructions
- Now, view the commit log:
git log
(Notice your commit is gone!) - Fix the conflicts manually (there are other ways, but let's keep it simple)
- Once the conflicts are fixed, print the status:
git status
- Stage the modified file for commit:
git add team.txt
- Continue the rebase:
git rebase --continue
- View the commit log once again:
git log
- Push your changes to
origin
:git push origin fix_name-spelling
- Notice the error
- Now, try again, but force push:
git push -f origin fix_name-spelling
- Check your PR and ensure it can be merged without conflicts
- Once it's ready to merge, I'll merge it
- Justin has started the work on each member's details, but needs help
- Add Justin's fork as another remote:
git remote add justin <repo-url>
- Fetch a branch from Justin's repo:
git fetch justin feat_add-member-details
- Notice the printout from this fetch
- Now, checkout the branch:
git checkout feat_add-member-details
- Now, checkout the other branch:
git checkout justin/feat_add-member-details
- Notice you are now in Detached HEAD Mode
- Jump back into the non-detached branch:
git checkout -
- Add your role and location data to your member file
- Add and commit your changes:
git add .
&git commit
- Push your changes to
origin
:git push origin feat_add-member-details
- PR your new branch to
upstream/main
- You member detail feature has a new request: add the year you joined ForeRock
- Open your member detail file, and add
year: <year joined>
at the bottom - Save your file
- Stage your changes:
git add .
- View your commit history:
git log
- Amend your previous commit:
git commit --amend
- Push your changes to
origin
:git push origin feat_add-member-details
- Oops, notice the error
- Try again, but now force push:
git push -f origin feat_add-member-details
- Review your PR once again for correctness
- Notice the two commits on your PR: one from me, and the other from you
- Once it's ready, I will merge it