-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Git CLI Workshop | ||
|
||
Learn the basics of Git through an interactive workshop. | ||
|
||
## Instructions | ||
|
||
### Getting started | ||
|
||
1. Fork this repository to your personal Github account | ||
2. Download or `git clone` your personal fork to your local computer | ||
3. Add this repo as `upstream`: `git remote add upstream <repo-url>` | ||
4. Review the commit log: `git log` | ||
5. Review the reference log: `git reflog` | ||
|
||
### Fix spelling error | ||
|
||
1. Create a new "fix" branch: `git checkout -b fix_name-spelling` | ||
2. Find your name within the `team.txt` file and correct its spelling | ||
3. Save your changes | ||
4. Review your Git status: `git status` | ||
5. "Stage" your change to be committed: `git add team.txt` | ||
6. Review your Git status: `git status` | ||
7. Commit your changes: `git commit` | ||
8. Push your changes to `origin`: `git push origin fix_name-spelling` | ||
9. PR your new branch to `upstream/main` | ||
|
||
### Fix conflicts | ||
|
||
1. Main has been updated, you can no longer merge your PR | ||
2. Switch your local `main` branch: `git checkout main` | ||
3. Pull updates from `upstream`: `git pull upstream main` | ||
4. Switch back to your "fix" branch: `get checkout -` | ||
5. Rebase your "fix" branch with `main`: `git rebase main` | ||
6. Your `rebase` will halt and ask you to fix the conflict | ||
7. Before you move on, familiarize yourself with the CLI instructions | ||
8. Now, view the commit log: `git log` (Notice your commit is gone!) | ||
9. Fix the conflicts manually (there are other ways, but let's keep it simple) | ||
10. Once the conflicts are fixed, print the status: `git status` | ||
11. Stage the modified file for commit: `git add team.txt` | ||
12. Continue the rebase: `git rebase --continue` | ||
13. View the commit log once again: `git log` | ||
14. Push your changes to `origin`: `git push origin fix_name-spelling` | ||
15. Notice the error | ||
16. Now, try again, but force push: `git push -f origin fix_name-spelling` | ||
17. Check your PR and ensure it can be merged without conflicts | ||
18. Once it's ready to merge, I'll merge it | ||
|
||
### Collaborating | ||
|
||
1. Justin has started the work on each member's details, but needs help | ||
2. Add Justin's fork as another remote: `git remote add justin <repo-url>` | ||
3. Fetch a branch from Justin's repo: `git fetch justin feat_add-member-details` | ||
4. Notice the printout from this fetch | ||
5. Now, checkout the branch: `git checkout feat_add-member-details` | ||
6. Now, checkout the other branch: `git checkout justin/feat_add-member-details` | ||
7. Notice you are now in Detached HEAD Mode | ||
8. Jump back into the non-detached branch: `git checkout -` | ||
9. Add your role and location data to your member file | ||
10. Add and commit your changes: `git add .` & `git commit` | ||
11. Push your changes to `origin`: `git push origin feat_add-member-details` | ||
12. PR your new branch to `upstream/main` | ||
|
||
### Ammending Additions | ||
|
||
1. You member detail feature has a new request: add the year you joined ForeRock | ||
2. Open your member detail file, and add `year: <year joined>` at the bottom | ||
3. Save your file | ||
4. Stage your changes: `git add .` | ||
5. View your commit history: `git log` | ||
6. Amend your previous commit: `git commit --amend` | ||
7. Push your changes to `origin`: `git push origin feat_add-member-details` | ||
8. Oops, notice the error | ||
9. Try again, but now force push: `git push -f origin feat_add-member-details` | ||
10. Review your PR once again for correctness | ||
11. Notice the two commits on your PR: one from me, and the other from you | ||
12. Once it's ready, I will merge it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# CLI Git Guide | ||
|
||
## `git clone` | ||
|
||
## `git remote` | ||
|
||
## `git log` | ||
|
||
## `git add` | ||
|
||
## `git status` | ||
|
||
## `git commit` | ||
|
||
## `git rebase` | ||
|
||
Commands: | ||
|
||
```text | ||
git checkout <source branch> | ||
git pull upstream <source branch> | ||
git checkout <target branch> | ||
git rebase <source branch> | ||
``` | ||
|
||
### Manually changing conflict | ||
|
||
If there were changes introduced to the same parts of content that you also altered, you will get a conflict. This is what will be printed in your terminal: | ||
|
||
```text | ||
Auto-merging team.txt | ||
CONFLICT (content): Merge conflict in team.txt | ||
error: could not apply 1ceecb2... fix(name): incorrect spelling | ||
Resolve all conflicts manually, mark them as resolved with | ||
"git add/rm <conflicted_files>", then run "git rebase --continue". | ||
You can instead skip this commit: run "git rebase --skip". | ||
To abort and get back to the state before "git rebase", run "git rebase --abort". | ||
Could not apply 1ceecb2... fix(name): incorrect spelling | ||
``` | ||
|
||
### Bulk solving rebase conflicts | ||
|
||
If you want to default to the changes on the source, not target, you can use the following command: | ||
|
||
```text | ||
git checkout --ours -- <filename> | ||
``` | ||
|
||
It's worth noting that `--ours` and `--theirs` during a rebase is opposite of a regular `git merge` conflict. | ||
|
||
## `git push` | ||
|
||
### Push failure | ||
|
||
When you have rewritten one or more commits, you will get the following error: | ||
|
||
```text | ||
To github.com:cerebrl/git-workshop.git | ||
! [rejected] fix_name-spelling -> fix_name-spelling (non-fast-forward) | ||
error: failed to push some refs to 'github.com:cerebrl/git-workshop.git' | ||
hint: Updates were rejected because the tip of your current branch is behind | ||
hint: its remote counterpart. Integrate the remote changes (e.g. | ||
hint: 'git pull ...') before pushing again. | ||
hint: See the 'Note about fast-forwards' in 'git push --help' for details. | ||
``` | ||
|
||
## `git reflog` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Andee | ||
Baylla | ||
Davved | ||
Goorge | ||
Gysell | ||
Justyn | ||
Loois | ||
Rian | ||
Rodreego | ||
Sammual | ||
Stowyen |