Basic use of git command operation

Source: Internet
Author: User

Linux Operations Command line:
mkdir-Create a folder,
CD-Toggle File path
PWD-Show file path
Ls-ah-You can view the hidden folder name (. git)
Cat file name-View file contents
RM File name-delete the specified file name

git operation command line:

git config--global user.name "your name"-Name the computer
git config--global user.email "your email"-Configure email address

Special: Git config--global core.longpaths true-when the error content is configured (file name too long), you can resolve the problem of too long file name

(This happens when I moogoose the module clone or push)

    git init-Initialize a warehouse (repository)
   & Nbsp;git Add filename-add file to warehouse
    git commit-m "Submit Interpreter"-Submit file to warehouse
    git Status-View submission Status, already file status
    git diff file name-View what the file specifically modified
    git Log-View the entire warehouse submission log
    git Log--pretty-oneline-one line view log
    git reset--hard head^-Fallback previous version (head^^ (last two versions) head~100 (upper 100 versions)
    git Reset--hard commit version number-back to the version that corresponds to the version number (the version can be only the first few digits)
    git Reflog- To view the command history action, you can scroll to the version of any version number
    git diff HEAD--File name-you can see the difference between the latest version in the workspace and the repository (uppercase HEAD can be lowercase)
     git Checkout--file name-undo the modified file or undo staging area added changes (the file name can be. On behalf of all files), here--it's important, if not, to "create a new branch"
    git reset HEAD file name-roll back from staging area to workspace (here just rollback to workspace), if you want to undo the change, Need to use the git checkout above--File command action undo modify,

If you've changed the wrong thing and submitted it to the repository, you can roll back git reset--hard head^ command-line operation version


---version fallback: git reset--hard head^
---Staging area fallback: Git reset HEAD file name
---file modification fallback: Git checkout--file name
(Three hierarchical relationships are different)
git rm file name-delete the file in the repository, and finally make sure to delete the commit, if the deletion error can be based on the above several fallback way to do the corresponding action

git remote add remote Repository address-Add remote warehouse address, remote warehouse name is usually origin default name remote Repository as origin can call other names (get name for remote repository)
If there is more than one collaborative development, you need to pull down and merge locally before you commit, before you can push up
git Clone remote Warehouse address

Git checkout-b Branch name-Create a branch and switch branches to that created branch (-b means Create branch and switch branches)
GIT Branch Branch name-Create a branch above the line can be equivalent to the following two lines of command
Git checkout branch name-switch branches
Git branch-View branch (front branch with * is the current commit branch)
Git Merge branch name-the current branch merges the specified branch
Git branch-d Branch name-delete branch
git log--graph-you can see the branch merge situation
---git log--graph--pretty=oneline-one line shows the merged graph,
---git log--graph--pretty=oneline--abbrev-commit-An abbreviated submission ID number on one line

Git stash-The main use for this branch of the reserved storage, wait until the debugging bug succeeds, then restore the original branch to continue the next work
git stash List-used to view the display of listing information for paused hold storage
git stash apply-revert to the normal state of the branch, after recovery, stash content is not deleted
git stash drop-use this command line for stash content removal
Git stash pop-restores the stash content as well
git stash apply [email protected]{0}-Specify the stash version status of the recovery branch

Git branch-d branch name-forcibly delete a branch that is not merged

Git remote-View information about the repository
Git remote-v-Show more detailed information
Git push Origin master-pushes the local master Master branch to the repository named origin in the default remote repository
Git push Origin branch name-pushes the local branch to the remote repository
Git pull-merges the contents of the remote Repository branch with the content of other co-members push to the branch, which may conflict after merging, requires manual local resolution of the conflict, and then push
Git pull repository name-Pull specify warehouse name and branch

Git tag tag number-add tag number (default most recently submitted content)
git tag tag number commitid-Specify a commit ID to add a label signature
Git tag-can see all tag numbers
Git show tag number-Displays the submission information displayed under this tab
Git tag-a tag number-m description commitid-a Specify tag name, m submit specified description, specify commit version number
Git tag-s tag number-M description commitid-s sign a label with the private key
Git tag-d tag number-delete tag number
git push warehouse name Tag name-Remote push tag name into the repository
git push repository name--tags-Push all tag names to warehouse
Git push warehouse name: refs/tags/Tag name-delete remote tag name (need to delete the label signature locally before deleting the signature in the warehouse)

git config--global alias. The actual command operator-for example, git config--global alias.st status when the input command executes: Git St returns OK







Basic use of git command operation

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.