Arvutiteaduse instituut
  1. Kursused
  2. 2019/20 kevad
  3. Koostöövahendid tarkvaraarenduses (LTAT.05.009)
EN
Logi sisse

Koostöövahendid tarkvaraarenduses 2019/20 kevad

  • Main
  • Lessons
  • Resources

Practice 4: Branching

By the end of this practice, you will know how to

  1. List, create, delete branches in Git
  2. Switch branches in Git
  3. Merge branches in git

Branching

  1. Fork (see last practice) the repository for this practice: https://github.com/CSE-2020/cse-prac4-branching
  2. Look at the list of branches of this repository on Github
  3. Clone your fork of the repository to your computer
  4. Look at the list of branches on your local copy of the repository. What do you notice?
  5. When we clone a repository, we don't actually download all the branches, so now you should only have one branch - master . Run the command git branch -a. What do you notice?
  6. When you switch to a branch that exists on a remote, git automatically creates this branch locally as well. Git sadly doesn't have a good command to download references to all branches from remote and create local branches for it. We can only see the list of all remote branches with git branch -a or run a bash script like the one in this StackOverflow thread.
  7. Create a new branch answers and switch to it
  8. Make sure you are on branch answers, not master. Use git status and git branch to see where you are
  9. git branch can accept many arguments that we didn't look at in the lecture. You can use git branch --no-merge to see branches that have not been merged into the current branch or git branch --merge to see branches that have been merged
  10. Use the commands introduced in the lectures or any third-party software to inspect the repository. Find answers to the following questions; write them to a file answers.txt and commit the file to the repository:
    1. What branches exist in this project?
    2. What branch has been merged into master?
    3. How many commits (in total) does the repository have?
    4. What commits belong to branch package that don't belong to the branch master?
  11. Switch back to the branch master.
  12. Create a new file 7.txt and commit it to the repository
  13. Look at the commit history with branches. See how the branch answers branches out from master
  14. Merge the branch answers into master
  15. Look at the commit history with branches. See how the branch answers merges back into master, but the pointer of answers is still on a separate branch.
  16. By default, Git pushes only the current branch. You need to push a branch explicitly, as shown in the lecture. Or you can use git push --all to push information of all branches.
  17. Push all changes to the remote using git push --all
  18. Use git branch --merge to see what branches have been merged into master and delete them. When deleting branches, remember that Git doesn't delete remote branches. use git push origin --delete <branch> to delete the required branches also in the remote

When everything is done, send a link to the Github page of your repository to the instructor in Slack.

Don't forget to fill the Quiz!

  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused