"Go" git command

Source: Internet
Author: User

Git uses

1. Git pull update server code to local
a). Git pull Origin Master is updating the code of the Origin repository to the local master Master branch

2. Git push commits the local code to the server

3. Git log View submission information
a). Git log-p View log information and changes
b). Git log-p-4 see log information and changes from the latest 4 times
c). Git log frameworks/View log information related to frameworks/directory modification
d). Git log--stat View log display file modification
e). Git log--stat packages/apps/contacts/view file modifications related to the log display for packages/apps/contacts/directory modifications

4. Git status View changes to working directory and code Warehouse

5. Git diff to see the difference between the working directory and the local warehouse or the different versions of the local warehouse
a). Git diff packages/apps/contacts/andoridmanifest.xml View Andoridmanifest.xml in the working directory and andoridmanifest.xml in the local repository
b). Git diff b46cae3b9a377bcd9cfc249a5778fce647feb961 dc94bf29aab18168e79d6496a89e47dba7a1d494 see the different two versions (Git diff History_old history_current)

6. Git commit commits the current modification
a). Git commit file1 file2-m "log Message" commits file1,file2 to the local repository
b). Git commit-a-M "Log message" commits all changes in the GIT index

7. Git add to add file to git index
a). Git add file3 file4 add file3,file4 to the GIT index

8. Git rm removes files from the git index
a). Git rm file3 removes file3 from the git index and deletes it locally
b). git rm--cached filename Removes the file from the git index without deleting the actual file

9. Git branch Add, delete, and check operations on a branch

a). Git branch Show all local branches
b). Git branch new_branch Create a branch named New_branch in the current version
c). Git branch-d new_branch forcibly delete a branch named New_branch
d). Git branch-r to view branches on the server
e). Git branch-a displays all branches of the server and local

Checkout git to switch and restore files in different branch

a). Git checkout branch1 switch to BRANCH1 branch
b). Git checkout origin/cmcc-b CMCC pull branch origin/cmcc from server to local CMCC branch
c). Git checkout/packages/apps/contacts/androidmanifest.xml will update the Androidmanifest.xml file from the last committed version, and the uncommitted parts will all be rolled back
d). Git checkout/package/app/contacts/to re-pull the files in this directory to the local, if you accidentally deleted the directory, you can use this to restore
e). Git checkout origin/m9002-b m9002 download Remote branch origin/m9002 to local branch m9002

Git reset completely rolls back the current working directory to the specified version number

a). Git reset [--fixed] 3204F2F0BDFD6ADA86C587B8927CDC5A15C586C1 only updates the index, does not update the working directory, which means that all local files are not updated
b). Git reset [--soft] 3204f2f0bdfd6ada86c587b8927cdc5a15c586c1
c). Git reset [--hard] 3204F2F0BDFD6ADA86C587B8927CDC5A15C586C1 force rollback to the specified version number, uncommitted and subsequent changes to this version are all erased
d). Git reset--hard origin/master Force and Master sync on the server

git merge

a). Git merge branch1 merge branch1 changes into the current branch

A. Git patch
a). Git format-patch-1 hit a patch that is currently being submitted, which is the last commit change
b). Git fromat-patch-1 6525c43add803bfee37cf5c1cb573ed8aecf529e hit a patch that specifies a specific time
c). Git format-patch-2 6525c43add803bfee37cf5c1cb573ed8aecf529e based on a two-time patch that specifies a specific version

. git am

git am xxx.patch Submit patch

git am--abort the git status back to its previous status to continue submitting patches.

GUI tools for git under TIG Linux
a). TIG view all records for the current warehouse
b). Tig packages/apps/launcher2/View all records under Directory packages/apps/launcher2/

15. Many commands can be added to the directory to limit the contents of the operation

. git config

git config--global color.ui true git uses color

git config--global core.editor vim using Vim editor

. Git stash

Git stash Hide working directory changes

Git stash pop recovery working directory changes

Git whatchanged

git whatchanged packages/apps/contacts/View file modification status under directory packages/apps/contacts/

"Go" git command

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.