- Push & pull
- Remotes
- Pull requests
- find a file with your
<UCO>.txt
and write down what’s the most valuable thing you learnt so far on this course - CI needs to pass
- BONUS: contribute also to
what_we_learnt.txt
(beware of rebase and merge conflicts!)
- Branches
- Tags
- Merging
- Stash
- Clone this repository (clone it again even if you have a copy locally)
- Run
git branch add-lab-description origin/add-lab-description
- Run
git branch wip-show-sample-commands origin/wip-show-sample-commands
- These commands will create local copies of branches from remote origin: in this repository
- Run
- Delete branch “wip-show-sample-commands”
- Does the “add-lab-description” top commit look okay?
- Fix the problem once you spot it
- Create a new branch that starts from "add-lab-description", name it “fix”
- Oh, that’s not a good branch name, sorry. Rename the branch from “fix” to “fix-add-lab-description”
- Merge fix-add-lab-description into main
- BONUS: push your local main into your fork
- EPIC BONUS: Create a pull request from fix-add-lab-description to this repository
You are still free to do this task.
Click only when you want to see the solution for this lab with the explanation for commands.
- Delete the branch:
git branch -D wip-show-sample-commands
(has to be-D
since the branch is not merged). git switch add-lab-description
, let's work on the "add-lab-description" branch.- There is a typo in README.md, we can fix it easily:
workflowwwwwwwwwwwwwwwwwwwwww
→workflow
. git commit -a -m 'fix typo in readme'
- we want to preserve the original commit.git switch -c fix
: instructions say to create this branch.- Uhhhh, make your mind! 😄
git branch -m fix fix-add-lab-description
git switch main && git merge fix-add-lab-description
: merged, sweet!- In order to push, we need to set up our fork remote, but let's do this properly:
git remote rename origin upstream
: we want our for to be the default and the actual upstream repo to be named "upstream"git remote add origin [email protected]:$USERNAME/mastering-git-class2-lab
: now to set up our forkgit fetch --all
: let's fetch all refs to be sure we set it up correctly
- Let's push to our fork's main to see our change:
git push origin main:main
(we are telling git to push our local branchmain
into our fork repository and name the branchmain
there: so basically put our new local commits from main into fork's main) - The best practice is to create pull requests from dedicated branches, not main, so let's push again:
git push origin fix-add-lab-description:fix-add-lab-description
- Time to create the PR!
Did you find a problem? Something doesn't work? Please ask or contribute a fix.