- (Be aware that if something goes wrong, you can always reset your local repository to match the remote by
git fetch origin
and thengit reset --hard origin/<branch name>
. - Create personal repo on github.com
- Clone this project
- Push the project to your own personal repository. Hint: You need to change the remote url by
git remote set-url origin <URL>
- Check github.com to make sure it’s there.
git status
- how does this look?- Edit a file - Change the Main class to include your own username and password.
git status
again. How does it look now?- Put the file that you edited into “staging”. Do this through the
git add <filename>
command. Hint you can user either a * or a . as a wildcard to add all files to staging git status
again. How does it look now?git commit -m "your message"
to commit your changes. Note that it’s very important to make good commit messages, so people can easily identify what you changed. For instance “I created a new method to compute a hash value” is good, where “i edited file” is bad.git push
and check github if your changes was pushed correctly- Find a partner
- Play rock, paper, scissors. The winner invites the looser to collaborate on the winner’s repo.
- The “looser” clones the winner repository.
- Create new branch with
git checkout -b <branch-name>
- Edit the “winner’s” code.
git commit
git push
- The winner changes the code on
master
to something else again. Remember togit add
andgit commit
- Merge the new branch into master by
git merge <branch name>
- You should get a merge conflict
- In IntelliJ you can fix merge conflicts visually by going to VCS -> Git -> Resolve conflicts. Pick the changed code.
git commit
git push
- On the “winner’s” computer, you use the command
git pull
to get the new changes. - On a piece of paper, try to illustrate the how git has changed. You can use the same structure as https://learngitbranching.js.org/ if you’d like.
- Use
git log
. Does the log fit your illustration? Tip: If you want to save the log in a file, you can use the commandgit log > log.txt
. This command add the output ofgit log
to a textfile calledlog.txt
Hvis i har mere tid, kan i lave øvelse 1-4 på https://learngitbranching.js.org/