In [1]:
name = '2015-12-11-meeting-summary'
title = 'Introducing Git'
tags = 'git, github, version control'
author = 'Denis Sergeev'
In [2]:
from nb_tools import connect_notebook_to_post
from IPython.core.display import HTML
html = connect_notebook_to_post(name, title, tags, author)
Today we talked about git and its functionality for managing code, text documents and other building blocks of our research.
We followed a very good tutorial created by Software Carpentry. There are hundreds of other resources available online, for example, Git Real.
Hence, this post is not trying to be yet another git tutorial. Instead, below is just a brief recap of what commands were covered during the meeting.
Set up your name and email so that each time you contribute to a project your commit has an author
git config --global user.name "Python UEA"
git config --global user.email "python@uea.ac.uk"
Create a new directory for a project
mkdir myproject
Go into the newly created directory
cd myproject
Make the directory a Git repository
git init
Check status of the repository
git status
Add a Python script to the repo (make the file staged for commit)
git add awesome_script.py
Commit changes with a meaningful message
git commit -m "Add awesome script written in Python"
git log
List all untracked changes in the repository
git diff
Differences with “head minus one”, i.e. previous, commit
git diff HEAD~1 awesome_script.py
Differences with a specific commit
git diff <unique commit id> awesome_script.py
Create a .gitignore file and put '*.pyc' line in it telling git will to ignore all Python bytecode files
echo '*.pyc' >> .gitignore
Include .gitignore in the repository
git add .gitignore
git commit -m "Add .gitignore file"
git status
git remote add origin git@github.com:<username>/<repository_name>.git
git push -u origin master
If you use git on Grace and have tried git push
to a GitHub repository, you have probably encountered the following error:
fatal: unable to access 'https://github.com/***/***/': error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm
One of the possible solutions here is to switch off SSL verification by adding the following line in your .bashrc file:
export GIT_SSL_NO_VERIFY=true
In [3]:
HTML(html)
Out[3]: