fix: consistent Git naming and explanations for some commands
This commit is contained in:
@@ -94,7 +94,8 @@ Now practice creating your own branch:
|
|||||||
2. Check the changes you committed before. You'll notice that they're gone!
|
2. Check the changes you committed before. You'll notice that they're gone!
|
||||||
3. Now edit a file or create a new file (perhaps GUIDE.md, content of the file doesn't matter) and add it and commit it on your `main` branch (hint: `git add .`, `git commit -m`)
|
3. Now edit a file or create a new file (perhaps GUIDE.md, content of the file doesn't matter) and add it and commit it on your `main` branch (hint: `git add .`, `git commit -m`)
|
||||||
- This way we create diverging branches. The `main` branch has changes as well as your new `my-feature` branch.
|
- This way we create diverging branches. The `main` branch has changes as well as your new `my-feature` branch.
|
||||||
- Run `git log --oneline --graph --all` to see how the tree is looking
|
- To see changes on the branch you're on, just run `git log --oneline --graph`
|
||||||
|
- Run `git log --oneline --graph --all` to see how the tree is looking, `main` should have diverged
|
||||||
4. Switch back to your branch `git switch my-feature`
|
4. Switch back to your branch `git switch my-feature`
|
||||||
5. The changes from the `main` branch are now gone. Check the changes you committed before. You'll notice they're back!
|
5. The changes from the `main` branch are now gone. Check the changes you committed before. You'll notice they're back!
|
||||||
|
|
||||||
@@ -104,12 +105,14 @@ Bring your work into main:
|
|||||||
|
|
||||||
1. Go back to the main branch `git switch main`
|
1. Go back to the main branch `git switch main`
|
||||||
2. Run a `git log --oneline --graph --all` to see that the `HEAD` is on your `main` branch
|
2. Run a `git log --oneline --graph --all` to see that the `HEAD` is on your `main` branch
|
||||||
3. It might be wise to first ensure that we're using Visual Studio Code to handle merge messages. If you haven't already set `git config --global core.editor "code --wait"` this sets Visual Studio Code to be the default editor for anything Git related.
|
- Hint: your `HEAD` is git's way of telling you <q>you're here</q>
|
||||||
|
3. It might be wise to first ensure that we're using Visual Studio Code to handle merge messages. If you haven't already set `git config --global core.editor "code --wait"` this sets Visual Studio Code to be the default editor for anything git related
|
||||||
4. Let's merge the recently created branch `git merge my-feature`
|
4. Let's merge the recently created branch `git merge my-feature`
|
||||||
5. Visual Studio Code should open with a commit message. In order to solidify the commit simply close the window. That tells Git that the commit message has been written and the change should be committed.
|
5. Visual Studio Code should open with a commit message. In order to solidify the commit simply close the window. That tells git that the commit message has been written and the change should be committed
|
||||||
6. Now run `git log --oneline --graph --all` and see your changes merge into the `main` branch!
|
6. Now run `git log --oneline --graph --all` and see your changes merge into the `main` branch!
|
||||||
7. Now let's clean up a bit, run `git branch -d my-feature` to remove the recently merged branch.
|
7. Now let's clean up a bit, run `git branch -d my-feature` to remove the recently merged branch
|
||||||
- If you hadn't merged the branch first this command would fail as Git will warn you that you have changes not merged into the `main` branch
|
- If you hadn't merged the branch first this command would fail as git will warn you that you have changes not merged into the `main` branch Remember, once we've deleted the branch, we can no longer access it, and it's lost forever. That's why there is a safeguard when changes are unmerged when running
|
||||||
|
- Technically it's possible to recover the branch, however this requires using `git reflog` within the git garbage collection period which is usually 30 days-ish. This is however advanced, but I'd recommend asking your local LLM a question like <q>How can I restore a deleted branch</q>. It will probably come up with the right answer
|
||||||
|
|
||||||
You should see your feature branch merged into main!
|
You should see your feature branch merged into main!
|
||||||
|
|
||||||
@@ -139,7 +142,7 @@ git merge another-feature
|
|||||||
|
|
||||||
### What is a Branch?
|
### What is a Branch?
|
||||||
|
|
||||||
A **branch** is a lightweight movable pointer to a commit. When you create a branch, Git creates a new pointer - it doesn't copy all your files!
|
A **branch** is a lightweight movable pointer to a commit. When you create a branch, git creates a new pointer - it doesn't copy all your files!
|
||||||
|
|
||||||
```
|
```
|
||||||
main: A---B---C
|
main: A---B---C
|
||||||
@@ -154,7 +157,7 @@ my-feature: D---E
|
|||||||
|
|
||||||
### What is HEAD?
|
### What is HEAD?
|
||||||
|
|
||||||
`HEAD` points to your current branch. It's Git's way of saying "you are here."
|
`HEAD` points to your current branch. It's git's way of saying "you are here."
|
||||||
|
|
||||||
```pwsh
|
```pwsh
|
||||||
# HEAD points to main
|
# HEAD points to main
|
||||||
@@ -181,7 +184,7 @@ main: A---B---C---M
|
|||||||
feature: D---E
|
feature: D---E
|
||||||
```
|
```
|
||||||
|
|
||||||
Git creates a merge commit `M` that has two parents (C and E).
|
git creates a merge commit `M` that has two parents (C and E).
|
||||||
|
|
||||||
**Fast-forward merge**:
|
**Fast-forward merge**:
|
||||||
```
|
```
|
||||||
@@ -194,7 +197,7 @@ After merge:
|
|||||||
main: A---B---C---D
|
main: A---B---C---D
|
||||||
```
|
```
|
||||||
|
|
||||||
If main hasn't changed, Git just moves the pointer forward. No merge commit needed!
|
If main hasn't changed, git just moves the pointer forward. No merge commit needed!
|
||||||
|
|
||||||
## Key Commands
|
## Key Commands
|
||||||
|
|
||||||
@@ -340,7 +343,7 @@ After completing this module, you understand:
|
|||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
Ready to continue? The next module covers **merge conflicts** - what happens when Git can't automatically merge changes.
|
Ready to continue? The next module covers **merge conflicts** - what happens when git can't automatically merge changes.
|
||||||
|
|
||||||
To start over:
|
To start over:
|
||||||
```pwsh
|
```pwsh
|
||||||
@@ -348,4 +351,4 @@ To start over:
|
|||||||
.\setup.ps1
|
.\setup.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
**Need help?** Review the commands above, or run `git status` to see what Git suggests!
|
**Need help?** Review the commands above, or run `git status` to see what git suggests!
|
||||||
|
|||||||
Reference in New Issue
Block a user