praktische aspekte der informatik - graphics.tu-bs.de · assignment a. create a git account on our...
TRANSCRIPT
![Page 1: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/1.jpg)
Praktische Aspekte
der InformatikMoritz Mühlhausen
Prof. Marcus Magnor
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 2: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/2.jpg)
Software VersioningGit basics, workflow, and commands
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 3: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/3.jpg)
Further Reading
Warning!The following slides are meant to give you
a very superficial introduction.
If you want to learn more, have a look at:
http://git-scm.com
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 4: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/4.jpg)
Outline
• What is versioning?
Naïve approaches
Smart approaches
• Git Workflow
Basic git commands
• Assignment: Check in your proposal
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 5: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/5.jpg)
A simple file server
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 6: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/6.jpg)
Lock-modify-unlock
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 7: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/7.jpg)
Copy-modify-merge
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 8: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/8.jpg)
Copy-modify-merge
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 9: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/9.jpg)
Git Basics
• Benefits:
Global revision numbers
No serialization (parallel editing)
Offline editing
Merging works most of the time
• Drawbacks:
Requires a disciplined workflow and maintenance!
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 10: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/10.jpg)
Git Basics
Initial checkout, and regular update to the newest version:
git init / git clone <url> / git pull
Make changes:
git add <files> / git mv <src> <dst>
Examine your changes:
git status / git diff [file]
Possibly undo some changes:
git reset [file] / git checkout --<file>
Commit changes:
git commit / git push
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 11: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/11.jpg)
Git Basics
Always use the update command to get the latest version:
$ git pull
Updating 7073847..a005fe8
Fast-forward
food/sandwich.h | 2 +-
food/sandwich.cpp | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
For bug hunting it is useful to look at old revisions by adding
$ git checkout <commit>
$ git blame <file>
$ git bisect
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 12: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/12.jpg)
Git Basics
Check the status of all local files compared to the repository:
$ git status
Changes to be committed:
modified: food/sandwich.h
Changes not staged for commit:
modified: food/sandwich.cpp
Untracked files:
food/food.txt
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 13: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/13.jpg)
Git Basics
$ git diff
index: 05f23b8..800e28a 100644
--- a/food/sandwich.cpp
+++ b/food/sandwich.cpp
@@ -1,5 +1,9 @@
#include "sandwich.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
int main(void) {
- printf("Sixty-four slices of American Cheese...\n");
+ printf("Sixty-five slices of American Cheese...\n");
}
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 14: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/14.jpg)
Git Conflicts
If there is a conflict, all relevant versions are still available in their
respective commit:
$ git pull
From http://git.cg.cs.tu-bs.de:6000/PADI/test
fbb93f8..f82df1b master -> origin/master
Auto-merging food/food.txt
CONFLICT (content): Merge conflict in food/food.txt
Automatic merge failed; fix conflicts and then commit the
result
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 15: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/15.jpg)
Git Conflicts
$ cat sandwich.txt
Top piece of bread
Mayonnaise
Lettuce
Tomato
Provolone
<<<<<<< HEAD
Salami
Mortadella
Prosciutto
=======
Sauerkraut
Grilled Chicken
>>>>>>> f82df1b22544bf943520a7669991f88b443fa81d
Creole Mustard
Bottom piece of bread
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 16: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/16.jpg)
You can manually merge those files:
• In editor by hand, remove the <<<, ===, >>> lines and merge them to
your desire
• Use $ git mergetool food/food.txt
You can avoid them beforehand:
$ git pull –s ours sandwich.txt
Always prefer your file over the current revision.
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 17: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/17.jpg)
Git Conflicts
You can then commit your merge:
$ git commit -a
Merge branch ‘master’ of http://git.cg.cs.tu-bs.de:6000/PADI/test
# Conflicts:
# food/food.txt
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# .git/MERGE_HEAD
# and try again
…
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 18: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/18.jpg)
Things to watch out for
• Commit often
• Always use understandable messages
• Only commit code that compiles
• Avoid conflicts early, by designating responsibilities.
• Do not commit temporary files!
• Do not commit ‘backup’ files!
https://graphics.tu-bs.de/teaching/ws1718/padi/
![Page 19: Praktische Aspekte der Informatik - graphics.tu-bs.de · Assignment A. Create a git account on our server Go to the website: git.cg.cs.tu-bs.de Create an account with your lastname](https://reader030.vdocuments.net/reader030/viewer/2022041207/5d610c3188c99383688b49bc/html5/thumbnails/19.jpg)
Assignment
A. Create a git account on our serverGo to the website: git.cg.cs.tu-bs.de
Create an account with your lastname as username.
B. Commit your project proposalCheck out your project’s directory:
git clone [email protected]:PADI/WiSe1718_Yourname.git
Copy your proposal (proposal.txt) into this directory. Make sure your proposal
is a text file and that it contains both your name as well as your
matrikelnummer.
https://graphics.tu-bs.de/teaching/ws1718/padi/