Git (and Redmine)
Notes
- the first section (first setup) and the concrete URLs are specific to Redmine
- the rest would be the same with any other remote machine which offers storing of git repositiories (e.g. GitHub or BitBucket)
First setup on Redmine
- Login and set a new password
- go to https://redmine.ms.mff.cuni.cz/login
- log in with your username (name.surname) and password
- your first password is temporary -- go to "My account" -- "Change password" and set a new password (and remember it)
- Setup the repository for this course
- go to https://redmine.ms.mff.cuni.cz/projects/undergrads
- click on your subproject
- Settings -- unselect "Public" -- Save
- Settings -- Members -- New member
- add "Rudolf Rosa" and "Zdenek Zabokrtsky" as "Reporters"
- Settings -- Repositories -- New repository
- SCM: Gitolite
- Identifier:
2017-npfl092
Filling your new repository -- VERSION A (git add remote)
- create a local repository
cd
mkdir 2017-npfl092
cd 2017-npfl092
git init
- add a README file
echo 'This is my repository for NPFL092.' > README
git status
git add README
git status
- commit the changes locally
git commit -m'adding README'
git status
- push your repository to Redmine
git remote add origin https://name.surname@redmine.ms.mff.cuni.cz/undergrads/surname/2017-npfl092.git
git push -u origin master
- you will need to enter your Redmine password
- you can also use SSH instead of HTTPS, which saves you some password typing, but requires you to set up SSH keys
git status
Filling your new repository -- VERSION B (git clone)
- clone your repository
cd
git clone https://name.surname@redmine.ms.mff.cuni.cz/undergrads/surname/2017-npfl092.git
cd 2017-npfl092
- Note: you can also use SSH instead of HTTPS, which saves you some password typing, but requires you to set up SSH keys.
- add a README file
echo 'This is my repository for NPFL092.' > README
git status
git add README
git status
- commit the changes locally
git commit -m'adding README'
git status
- push changes to Redmine
git push
- you will need to enter your Redmine password
git status
Synchronizing changes
- make a new clone of the repository at a different place
cd; mkdir new_clone_of_repo; cd new_clone_of repo
git clone https://name.surname@redmine.ms.mff.cuni.cz/undergrads/surname/2017-npfl092.git
cd 2017-npfl092
- make some changes here, stage them, commit them locally, and push them to Redmine
echo 'This repo will contain my homework.' >> README
git add README
git commit -m'adding more info'
git push
- go back to your first local repo and get the new changes from Redmine
cd ~/2017-npfl092
cat README
git pull
cat README
Regular working with your repo
- go to a directory containing a clone of your repository (or make a new one with
git clone
if on a different computer)
- synchronize your local repo with the repo on Redmine with
git pull
- do any changes to the files, create new files, etc.
- view the changes with
git status
(and with git diff
to see changes inside files)
- stage new/changed files that you want to become part of the repo with
git add
(untracked files are ignored by git)
- create a new snapshot in your local repo with
git commit
- synchronize the repo on Redmine with your local repo with
git push