As an on-the-way-to-becoming-a-serious developer, I think I had better get familiar with some source code manager software, and that is: Git.
As I learn how to use git, I want to keep track of what I have learned, and keep it down so I can go back and see should I forget it. This is supposed to be a update-if-needed list. So here are some git commands:
- To make a directory git-aware, i.e. to initialize a git repository:
1 |
git init |
- To check status:
1 |
git status |
- To add file to staging index:
1 |
git add index.html |
- To commit changes:
1 |
git commit -m "some changes" |
- To switch to another branch:
1 |
git checkout new_branch |
- To discard changes on file in working directory:
1 |
git checkout -- index.html |
ps: — means not to care about branches, but just files in current branch.
- To unstage file:
1 |
git reset HEAD index.html |
- To change a file back to one of previous states:
1 |
git checkout 8a64b9a6871 -- index.html |
where 8a64b9a6871 is a SHA of previous commit.
- To view previous commits:
1 |
git log -n 10 |
where -n limits how many history commits to show.
- To reset all files to a previous state:
1 |
git reset 8a64b9a6871 |