GIT
Basics of git
a stream of snapshots
Git thinks of its data more like a series of snapshots of a miniature filesystem.
nearly every operations is local
We have the entire history of the project right there on our local disk, most operations seem almost instantaneous
three states
- committed means that the data is safely stored in your local database.
- modified means that you have changed the file but have not committed it to your database yet
- staged means that you have marked a modified file in its current version to go into your next commit snapshot
three main sections of a Git project
- working directory
- staging area
- .git directory(repository)
Getting Help
|
|
Getting a GIT Repository
Two ways:
You can take a local directory that is currently not under version control, and turn it into a Git repository
1git initYou can clone an existing Git repository from elsewhere
1git clone https://github.com/libgit2/libgit2through https or SSH
Recording Changes to the Repository
|
|
ignoring files
-> .gitignore file
diff
to see what you’ve changed but not yet staged
|
|
to see what you’ve staged that will go into your next commit
|
|
commit your changes
|
|
we could find that, the branch we commited to (master), what SHA-1 checksum the commit has (463dc4f), how many files were changed, and statistics about lines added and removed in this commit
skipping the staging area
let u skip the git add
part
|
|
don’t have to run git add
on the file in this case before u commit. -a
flag includes all changed files. This is convenient, but be helpful, sometimes this flag will cause u to include unwanted changes.
remove files
|
|
remove the file from your tracked files which means remove it from your staging area, and also removes the file from your working directory so you will not see it as an untracked file the next time around
|
|
If you modified the file and added it to the staging area already, must force the removal with the -f
option. This is a safety feature to prevent accidental removal of data that hasn’t yet been recorded in a snapshot and that can’t be recovered from Git.
|
|
Keep the file in your working tree but remove it from your staging area. In other words, you may want to keep the file on your hard drive but not have Git track it anymore.
|
|
rename a file in git, which equals to
|
|