Post date: Apr 27, 2014 8:09:14 AM
From my perspective, I think the best git or even github tutorial for an absolute beginner is from git-scm online book period. It explains very well about the concept, motivation and how to use the git tool to fulfill our needs.
I found this Github tutorial very useful:
There are also great examples using git for version control on IPython Notebook:
http://nbviewer.ipython.org/github/fperez/reprosw/blob/master/Version%20Control.ipynb
There are two different ways to start using Github:
In this case you start create project repo on your own local machine (laptop, desktop) first, and you want to upload the repo to Github later.
$ git init
$ git add readme.txt
$ git commit -m 'This is my first checkpoint'
https://github.com/kittipatkampa/myproj
$ git remote add origin https://github.com/kittipatkampa/myproj.git
$ git push origin master
$ git push --force origin master
$ git add readme.txt
$ git commit -m 'some additional comments are added to the end of the file'
$ git push origin master
$ git remote -v
This use case is much easier and less problematic to the previous one.
https://github.com/kittipatkampa/myproj2
$ git clone https://github.com/kittipatkampa/myproj2
git init
or git remote add
anymore because when the project is cloned, hence those are initialized for you already.I want to build a git repo for a directory of my python examples and I also want to push it to Github. Here is what I do:
/Users/kittipat/Dropbox/research/python_dev
git status
. Since my folder has not been initialized, the output is empty:kittipat python_dev $ git status
fatal: Not a git repository (or any of the parent directories): .git
git init
.kittipat python_dev $ git init
Initialized empty Git repository in /Users/kittipat/Dropbox/research/python_dev/.git/
kittipat (master #) python_dev $ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.ipynb_checkpoints/
date_time_conversion.ipynb
demo_decision_tree_v1.ipynb
demo_nice_pivot_table.ipynb
get_leaf_node_id.ipynb
iris.pdf
iris.png
lib_order_segmentation_python3.zip
lib_order_segmentation_python3/
my_tutorial/
programming_problems/
tsne_python/
nothing added to commit but untracked files present (use "git add" to track)
git add
. After that, I checked the repo status again and found 4 files are displayed on the stage area awaiting for commit.kittipat (master #) python_dev $ git add *.ipynb
kittipat (master #) python_dev $ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: date_time_conversion.ipynb
new file: demo_decision_tree_v1.ipynb
new file: demo_nice_pivot_table.ipynb
new file: get_leaf_node_id.ipynb
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.ipynb_checkpoints/
iris.pdf
iris.png
lib_order_segmentation_python3.zip
lib_order_segmentation_python3/
my_tutorial/
programming_problems/
tsne_python/
git commit -m 'your message'
.kittipat (master #) python_dev $ git commit -m 'all ipynb files are added and first-committed'
[master (root-commit) a2df0d9] all ipynb files are added and first-committed
4 files changed, 2875 insertions(+)
create mode 100644 date_time_conversion.ipynb
create mode 100644 demo_decision_tree_v1.ipynb
create mode 100644 demo_nice_pivot_table.ipynb
create mode 100644 get_leaf_node_id.ipynb
kittipat (master) python_dev $ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.ipynb_checkpoints/
iris.pdf
iris.png
lib_order_segmentation_python3.zip
lib_order_segmentation_python3/
my_tutorial/
programming_problems/
tsne_python/
nothing added to commit but untracked files present (use "git add" to track)
python_example
.https://github.com/kittipatkampa/python_example.git
git remote
. If output is empty, the folder does not have any remote repo yet.git remote add origin <git URL>
.kittipat (master) python_dev $ git remote add origin https://github.com/kittipatkampa/python_example.git
git push -u origin master
.kittipat (master) python_dev $ git push -u origin master
Username for 'https://github.com': kittipatkampa
Password for 'https://kittipatkampa@github.com':
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 72.91 KiB | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/kittipatkampa/python_example.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
Further resources: