- create a new repo
- clone to local
- .gitignore
- Markdown
- add a python file and run
- commit the file and push
- add another python file
- commit the file and push
- revert to a previous commit
- push
create files, commit and upload:
$ git clone https://github.com/harrywang/test.git
$ cd test/
$ atom .
$ open .
$ python test1.py
$ git status
$ git add .
$ git commit -am 'changed readme and added a python file'
$ git push
add another file:
$ python test2.py
$ git status
$ git add .
$ git commit -am 'added another python file'
$ git push
check commit history, find a previous commit
$ git log
commit 89021ead57939d79dafbf6dda6a24d410429f43a (HEAD -> master, origin/master, origin/HEAD)
Author: Harry Wang <harryjwang@gmail.com>
Date: Tue Feb 11 15:39:30 2020 -0500
added another python file
commit 8e5df4d9338422004fa4eda8db63c7a5a651ddc6
Author: Harry Wang <harryjwang@gmail.com>
Date: Tue Feb 11 15:37:18 2020 -0500
changed readme and added a python file
commit ee6d9f9fb7dcf6490af947842cdc1417e4ac94ac
Author: Harry Wang <harryjwang@gmail.com>
Date: Tue Feb 11 15:32:55 2020 -0500
Initial commit
optinal commands
- check out a previous commit and switch back
$ git checkout 8e5df4
$ git checkout master
- revert a previous commit
$ git revert 8e5df4
- roll back to a previous commit DANGER!!! you lost all commits after the one you are rolling back to
$ git reset --hard 8e5df4d
$ git push -f