This page is located in archive.

Lab 11 - Version Control

Reminder of essential commands


git init - start a repostiory in this folder

git clone *location* - copy the remote repository into the current folder

Basic file operations

git add filename - flag the file to be commited

git commit -m “message” - create the commit

git diff filename - see how the file has changed since it was last commited

git status - see which files have changed since the last commit

Moving around

git log - see the history

git checkout *hash* - set the repository to the state at this commit


git remote add *aliasName* *aliasLocation* - set up a new remote location git remote remove *aliasName* - remove remote git remote show - see all remotes

git pull *aliasName* *branch* - bring remote commits into the current repository git push *aliasName* *branch* - put any local-only commits onto the remote machine


git checkout -b *newbranchname* - creates a new branch from the current repositories situation


Exercise 1: Pushing to github

Use the folder/code from the previous lab. Run “git init” to make it into a repository. Add your files and commit them.

Create an account on github.com Push your work there.

Create a basic readme file called “Readme.txt”, make sure it is spelled exactly like this (including capitals). Add this as a second commit and push it to github also. AFTER COMMITING, make another change to the readme, but do not commit it.

Exercise 2: Push to someone else's repo

Find a partner. Clone their github repository from ex 1. Add your name to a new line in their readme. Push it back to their repository (you may need them to grant you access in the github web interface).

Exercise 3: Merge everything

Once someone has modified your online repository, pull the changes. Read the messages and figure out how to do this. Once you have your changes and theirs merged, push it back to the repository. Get your partner to run git pull and they should have everything on their machine.

courses/be5b99cpl/labs/lab11.txt · Last modified: 2023/12/05 19:31 by brouggeo