Git command parameters and Usage Details
Git command (gnu interactive tools)
Function Description: file administrator in text mode.
Syntax: git command
Note: The Git command is used to manage files. It is similar to Norton Commander in DOS and has an interactive operation interface. Its operation method is almost the same as that of Norton Commander:
F1: Execute the info command to query the command information. You are required to enter the name you want to query.
F2: Execute the cat command to list the file content.
F3: Execute the gitview command to view the file content.
F4: Execute the vi command to edit the file content.
F5: run the cp command to copy a file or directory. You are required to enter the target file or directory.
F6: Execute the mv command, move the file or directory, or change its name. You are required to enter the target file or directory.
F7: run the mkdir command to create a directory.
F8: Execute the rm command to delete files or directories.
F9: Execute make commands. When executing commands or compiling programs in batches, you are required to enter relevant commands.
F10: Leave the git file administrator.
----------------- Use the Git command -------------------------------
Git is a distributed version control tool. This article begins with introducing Git and focuses on the basic commands and usage skills of Git, so that you can try to use Git at the same time, experience the impact of a version control tool on development is as follows:
The first part introduces some common Git commands, which are interspersed with the basic concepts and principles of Git.
The second part focuses on how to use Git. At last, you will create an open-source project on Git Hub to start your Git practical journey.
What is Git?
Git defines Wikipedia: it is a free, distributed version control tool, or a source code management tool that emphasizes high speed.
Git was initially developed by Linus Torvalds for Linux kernel management. Each Git working directory is a completely independent code library with complete history and version tracking capabilities, independent of the network and central server.
The emergence of Git has reduced the pressure on many developers and open-source projects to manage branch code. Due to its good control of branches, developers are encouraged to contribute to projects they are interested in. In fact, many open-source projects, including Linux kernel, Samba, X.org Server, and Ruby on Rails, have transitioned to using Git as their own version control tools. For developers who like to write code, there are two major advantages: We can submit our own code and view the code version anywhere (on the subway station at work; we can open many branches to practice our ideas, and the overhead of merging these branches is almost negligible.
Git 1 + 1
Now I will go to the real topic of this article and introduce the basic commands and operations of Git, starting with the initialization, basic operations, and unique common commands of Git version libraries, let everyone start using Git.
Git usually has two methods for initialization:
Git clone: this is a simple initialization method. when you already have a remote Git version library, you only need to clone it locally.
Example: git clone git: // github.com/someone/some_project.git some_project
The above command is to clone the remote repository of 'git: // github.com/someone/some_project.git' to the external some_projectdirectory.
Git init and git remote: This method is a little more complicated. When you create a local working directory, you can enter this directory and use the 'git init 'command for initialization, in the future, Git will control the version of the files in this directory. If you need to put it on a remote server, you can create a directory on the remote server, and record accessible URLs. You can use the 'git remote add' command to add a remote server,
Example: git remote add origin git: // github.com/someone/another_project.git
The above command adds the URL address 'git: // github.com/someone/another_project.git', which is called the remote server of origin. when the code is submitted later, you can only use the origin alias.
GitHub tutorials
Git tag management details
Git branch management
Git remote repository details
Git local Repository (Repository) Details
Git server setup and Client installation
Git Overview
Git basic commands
Now we have local and remote version libraries. Let's try using the basic Git command:
Git pull: Updates code from other version libraries (either remote or local) to the local machine, for example: 'git pull origin master' is to update the code of the source database version to the master branch of the local master. This function is similar to the SVN update function.
Git add: adds the modified or newly added files to the Git index. Adding the files to the Git index indicates that the files are recorded in the version history, this is also a step that needs to be executed before submission, such as 'git add app/model/user. rb will add app/model/user. the rb file is written to the Git index. This function is similar to the SVN add
Git rm: delete files from the current workspace and indexes, such as 'git rm app/model/user. rb'. This function is similar to the rm and del functions of SVN.
Git commit: submits changes to the current workspace, similar to the SVN commit command, such as 'git commit-m story #3, add user model ', -m must be used to input a piece of submission information for submission. This function is similar to the SVN commit
Git push: update the local commit code to the remote version library. For example, 'git push origin' updates the local code to the remote version library named orgin.
Git log: View historical logs. This function is similar to the SVN log.
Git revert: to restore a version modification, you must provide a specific Git version number, for example, 'git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20 '. The git version number is a generated hash value.
The above commands are almost all public in each version control tool. Next we will try some unique Git commands:
Git branch: adds, deletes, and queries branches. For example, 'git branch new_branch' creates a new branch named new_branch from the current working version, 'git branch-D new_branch' will force the branch called new_branch to be deleted, and 'git branch' will list all local branches
Git checkout: Git checkout has two functions. One is to switch between different branchs. For example, 'git checkout new_branch 'switches to the new_branch branch; another function is to restore the Code, for example, 'git checkout app/model/user. rb, the user. the rb file is updated from the previous submitted version. All unsubmitted content will be rolled back.
Git rebase: the two figures below will be clear. After the rebase command is executed, the pivot point is actually moved from C to G, so that the Branch has the function from C to G.
Git reset: roll back the current working directory completely to the specified version number, assuming, for example, we have a A-G five times to submit the version, where C version number is bbaf6fb5060b4875b18ff9ff637ce118256d6f20, we executed the 'git reset bbaf6fb5060b4875b18ff9ff637ce118256d6f20 ', then the result is only three submitted versions of the A-C.