Git for Dummies (like me)
This is my personal Git cheat-sheet for this course. I am new to git as well, it is a very new technology. We use the latest technology in the P2 course because we feel that the technology in a course should always be up to date, so you are ready to work on the job market and to contribute to open-source projects.
Here is my Git cheat sheet.
Download Problem Set from the Server
This cheat-sheet assumes your group number is zero zero.
git clone git@pinocchio.unibe.ch:group00 cd group00
This downloads your group repository from the server, and changes the command-line to group folder.
git config --global user.name "Joe Example" git config --global user.email "joe@example.com" git remote add p2ubungen git@pinocchio.unibe.ch:p2ubungen
This sets the preferences for your user name, for your email and for the P2 problem set server (whose name is p2ubungen).
git pull p2ubungen master
This downloads the P2 problem set to your computer (whose name is master, don’t ask me why).
You are ready to solve the exercises now!
Upload the Solution of your Problem Set
git add . git commit -m "Uploading the solution" git pull && git push
This uploads your files to the server. It does so in three steps: it adds your solution to the added files, and commits the added files to committed files, and pushes the committed files to the server. So obviously there are four levels where your files can be 1) on the file system 2) added 3) committed and 4) on the server. To correct your problem set we look at the files on the server only, so make sure they are on the server.
Professional gitters refer to the four levels as, 1) working tree, 2) index or stage area, 3) master, and 4) origin/master.
Is the Solution, like, really on the Server?
git fetch && git status
This checks if your files are on the server. You should see
# On branch master nothing to commit (working directory clean)
if the file system and the server have the same content. If you see anything else, your solution is probably not on the server and you should repeat the steps above.
Don’t forget to upload your solutions by Friday, 04:00am in the night 04:00 pm in the afternoon, but no later. We do not accept any solutions after the exercise hour.
>> Don’t forget to upload your solutions by Friday, 04.00am..
The exercise hour is at 4.00 pm , guess. Do we now have to hand in the solutions until the beginning of the exercise hour or until 4.00 am??
This is a bit too terse for me. Which of the many tutorials on the web would you recommend? I want to understand better the story of local and remote repos without having to read 200 pages.
You’re right, I meant to say 4:00 pm, should have better just used European notation.
@Oscar Nierstrasz this is as far I’ve understood it. Of course, master is the name of the current local branch and origin/master is the name of the current branch on the remote repository prefixed with the name of the remote repository. Also a remote repository is not actually a server but just like a local repository that happens to be accessed through ssh on another machine. For for more information you best refer to Niko though.