Git Learning Resources: Pro git (Chinese version) learn git in your browser for free with Try git.git common commands reference common git command list
- The role of star is to collect, the purpose is to facilitate later search.
- Watch's role is attention, and the purpose is to wait for the author to update when you can receive notifications.
- The purpose of the fork is to participate, so that you can add new content and then pull the Request to merge your changes with the original contents of the main repository.
Fork can copy someone else's project to your account. However, one drawback is that when the source project is updated, the branch you fork is not updated together and needs to be updated manually. After fork, you can typically see an SSH or HTTPS access address with its own git name. For example:[email protected]: fuleying/parrots.git can ssh without password git push!! Https://github.com/fuleying/parrots.git participate in other people's open source projects, just visit its Project homepage, point "Fork" in its own account under the cloning of a warehouse, and thenuse the SSH URL to clone from your account, because only the warehouse with the SSH URL link will be able to push the changes. When the development is finished, push it to your own warehouse. If you want the official library of your fork to accept your changes, you can launch a pull request on GitHub.
- Start by creating a new remote repository on GitHub Git-learn, and you'll see an SSH or HTTPS access address with your git name.
Https://github.com/fuleying/git-learn.git
[email protected]: Fuleying/git-learn.git
- Create a local folder with the same name Git-learn and go to the folder directory
- Git init initializes an empty warehouse
- Create files, git add, incorporate files into version control, multiple files can be included in
- Git commit-m "First commit" for offline submission, complete the inclusion operation
- Add remote repository origin, that is, use the string origin to refer to the corresponding warehouse address, origin is the remote repository in the local abbreviation
git remote add origin [email protected]:fuleying/git-learn.git
- Push the local master branch to the remote repository origin GIT push Origin master
git remote to see which repositories are currently configured
git remote -v --verbose的简写,显示远程仓库对应的克隆地址
Git snapshot
Git copies the changed files directly, creating a new snapshot of the Blob type, rather than the diff from the previous version. Instead of documenting the specific differences of each file in each version.
So once you need to see a version of the direct load, and the other differential version control needs to do the merge, so fast. Space change time.
Not every current version needs to be backed up, and to improve performance, if the file does not change, Git does not save it again, but only a link to the last saved snapshot.
Git will be in the hidden directory. In Git, there is an object that is regularly optimized to ensure the balance of snapshot space and read time.
Four basic types of git
-
BLOBs: Each BLOB represents one (version) file, and the blob contains only the data of the file, ignoring the other metadata of the file, such as name, path, format, and so on.
-
Tree: Each tree represents a directory of information, including BLOBs in this directory, subdirectories (corresponding to sub-trees), file names, paths, and other meta-data. Therefore, for directories with subdirectories, Git is the equivalent of storing nested trees.
-
Commit: Each commit records all metadata that commits an update, such as the tree that points to, the parent commit, the author, the submitter, the date of submission, the submission log, and so on. Each commit points to a tree object, which records the directory information at the time of the commit. A commit can have multiple (at least one) parent commits.
-
Tag:tag is used to refer to an object of the above type with a name that is easy for the developer to remember, usually for a commit.
Git Special Nouns
- Workspace: A workspace that extracts all files and directories from a compressed object database in a git directory to start a subsequent work called a working directory.
- Index/stage: Staging area, usually put in Git directory. Sometimes people call this file an index file, but the standard term is called a staging area.
- Repository: The warehouse area (or local warehouse), which is the local. Git directory.
- Remote: Repository
The basic Git workflow is as follows:
- Modify some files in the working directory.
- Take a snapshot of the modified file and save it to the staging area.
- Commit the update to permanently dump the file snapshot saved in the staging area to the Git directory.
git fetch到远程仓库中拉取从你上次克隆以来别人上传到此远程仓库中的所有更新(或是上次 fetch 以来别人提交的更新)。fetch命令只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支,只有当你确实准备好了,才能手工合并。
git fetch origin来同步远程服务器上的数据到本地。该命令首先找到origin是哪个服务器,然后从上面获取你尚未拥有的数据,更新你本地的数据库,然后把origin/master的指针移到它最新的位置上。
git cloneThe local Master branch is automatically created to track the master branch in the remote repository.git PullWhen data is fetched from the remote repository of the original clone, it is merged into the current branch in the working directory.
Git Getting Started Guide