Git Common commands and git Common commands

Source: Internet
Author: User
Tags how to use git git commands ruby on rails

Git Common commands and git Common commands
===== Git Common commands ====


=== 1.Git documentation ===


Git Chinese Document viewing address: http://git.oschina.net/progit/

=== 2.Git basic commands ===


Git config -- global user. name // set the global user name without adding gloabl as a local
Git config -- global user. email // set the global user mailbox.
Git -- bare init // initialization git does not generate the. git directory, and there is no work tree ). Used for remote repository initialization.
Git init // initialize git to generate the. git directory
Cat. gitignore // ignore the trace file according to the rule configuration.
Git clone url // clone the project from the url path to the local repository.
Git status // view the File status in the working directory.
Git add file // add the file or path to the temporary storage area.
Git reset HEAD file // withdraw the file from the temporary storage area.
Git checkout -- file // cancel modification to the file.
Git rm file // delete files-cached does not delete local files-f force Delete
Git diff // view the differences between the modified file and the saved file-staged // The Difference Between the saved file and the last submitted file.
Git commit-am "txt" // submit the files in the temporary storage area and modified files to the warehouse txt for record.
Git log // you can view the submission history through gitg.
Git fetch pd // capture data from the remote inventory pd Library to the local git pull.
Git pushes the pd master // pushes the local master branch to the pd remote repository. Git push [remote repository name] [local branch]: [remote branch]
/Xxx *
If the remote warehouse is not bare init, the result is displayed when the local warehouse pushes the branch where the remote warehouse is located.
Does not apply to the work tree. If the remote repository is not on the push branch, you can. (Remote warehouse does not
Work tree required)
×××××××××××××××××××××××××××××××××××××××××××/

=== 3.Git remote Command ===




Git remote-v // view the list of the name and address of the current remote repository.
Git remote show wepu // view wepu information of the remote Repository
Git remote add test url // add a remote repository named test.
Git remote rename pd paul // change the remote repository pd name to paul
Git remote rm paul // remove the remote repository paul

=== 4.Git branch command ===




A branch is a history of looking back from a submitted object. In essence, it is a variable pointer (HEAD) to a commit object. Each commit will automatically move forward.
Git branch // view the current repository branch
Git branch-v // Add to display the information of the last submitted object
Git branch-a // view the remote repository branch
Git checkout-B A // create and point to branch A = git branch A + git checkout
Git branch-d A // Delete branch
Git push pd: A // Delete branch A on the remote repository. For details about the omitted local branch format, see Basic commands.
Git merge A // merge branch A into the current branch to form A new commit. When both branches modify data for the same row of a file
You need to resolve the conflict. After the solution is completed, execute add and commit
Git rebase A // merge branch A into the current branch to form A new commit. When both branches modify data for the same row of A file
Manually resolve the conflict. After the solution is completed, add. rebase-continue
Git rebase-onto master a B // retrieve B branch, find out the changes after the common ancestor of B and A branch, and rebase the master Branch
Git cherry pick commitID // submit other branches to the current branch. First, git log to confirm the commitID of the submitted object to be moved.
Git stash // put aside all current changes. First git add. add all the changes to the temporary store, and then git stash save "detial"
At this time, the work platform will return to the version before the change, if you need to recover: git stash apply
/Xxx *
Rebase: if the submission object in the Branch has been published to the public warehouse, it is recommended that you do not perform
Rebase operation. Because rebase will discard some existing submitted objects and then create different new
Object. Confusion may occur after code synchronization.
×××××××××××××××××××××××××××××××××××××××××××/
What are common git commands?

Git clone
Git push
Git pull
The three have the highest usage.

How to Use git mv command

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... the remaining full text>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.