# git demo. Single developer and local repository. # Let's move to a safe place: cd /tmp/ # Run git. It's harmless :-) git # Ask git about what it knows this of directory or parent directories: git status # Introduce yourself to git: git config --global user.name "Emanuele Olivetti" git config --global user.email "olivetti@fbk.eu" # ... and check it: git config user.name git config user.email git config -l # Move to the directory where we want to do VC: mkdir /tmp/demo_git_single_local cd /tmp/demo_git_single_local # Create a git repository within the current directory: git init # Verify you have a brand new ".git/" directory: ls -al . # ...full of interesting things...: ls -al .git/ # Ask git about the current directory: git status # Create a file named hello.py echo "print 'hello.'" > hello.py # ...check status: git status # ...and put hello.py under git VC. # First add hello.py to the staging area: git add hello.py # Check how the status changes: git status # Now record changes to the repository: git commit -m "My first commit. A big step for the mankind." # Check status again, it is instructive: git status # Edit hello.py some more: echo "import numpy as np" >> hello.py echo "print np.random.rand(3)" >> hello.py # See how the status changes accordingly: git status # show changes between current and staged files: git diff # Add changes into the staging area (index): git add hello.py # show how the status changes accordingly: git status # Edit again hello.py echo "print np.eye(4)" >> hello.py # Commit changes from the staging area (only): git commit -m "Improved docstring." # Verify that changes not added to the staging area were not recorded: git diff # commit all changes of hello.py skipping staging area: git commit hello.py -m "Added beautiful eyes." # Edit hello.py again and create more files: echo "print np.subtract.outer(np.random.rand(3),np.random.rand(2))" >> hello.py echo "import time" > clock.py echo "print time.ctime()" >> clock.py # inspect changes before commits: git status git diff # commit all changes made in all files skipping staging area: git add clock.py git commit -a -m "Added a swiss clock and improved hello.py." # See the logs of all commits: git log # See the logs of all commits with the GUI: gitk # Get crazy and mess with your files: echo "printttt 'I hate you...'" > hello.py rm clock.py # Oh no! What I've done! Shame on me! git status git diff # Relax buddy... you are using git :-) # Get rid of the last untracked changes: git checkout . ls git status git diff