refactor-reset-revert #1
@@ -78,36 +78,15 @@ git show <merge-commit-hash>
|
||||
|
||||
Now practice creating your own branch:
|
||||
|
||||
```pwsh
|
||||
# Create and switch to a new branch
|
||||
git switch -c my-feature
|
||||
|
||||
# Verify you're on the new branch
|
||||
git branch
|
||||
```
|
||||
|
||||
The `*` shows which branch you're currently on.
|
||||
1. Create a new branch with the name `my-feature` using `git switch -c my-feature`
|
||||
2. Check which branch you're on with `git branch`. The `*` shows which branch you're currently on.
|
||||
|
||||
### Part 3: Make Commits on Your Branch
|
||||
|
||||
Add some changes to your branch:
|
||||
|
||||
Create or edit a file then add and commit
|
||||
```pwsh
|
||||
# Create a new file or modify an existing one.
|
||||
# Stage and commit
|
||||
git status # see the files that are untracked or changed
|
||||
git add .
|
||||
git commit -m "Add my feature"
|
||||
|
||||
# Create or edit another file
|
||||
# Make another commit
|
||||
git status # see the files that are untracked or changed
|
||||
git add .
|
||||
git commit -m "Expand feature documentation"
|
||||
|
||||
git log --oneline --graph --all # see how your branch is moving forward from main
|
||||
```
|
||||
1. Create a new file called `DOCS.md` and add some content. What doesn't matter, just something.
|
||||
2. Add and commit the `DOCS.md` file (use the commands from `01-basics` module).
|
||||
3. Add some more content to the `DOCS.md` file, add and commit the changes.
|
||||
4. Now check how the tree is looking with `git log --oneline --graph --all`
|
||||
|
||||
**Important:** Changes on your branch don't affect main!
|
||||
|
||||
@@ -117,7 +96,7 @@ git log --oneline --graph --all # see how your branch is moving forward from mai
|
||||
- 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
|
||||
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 notive 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!
|
||||
|
||||
### Part 4: Merge Your Branch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user