Git common command quick check table

Source: Internet
Author: User
Tags diff

One, Git common command fast-track

Git branch view all local branches
Git Status View current status
Git commit Commit
Git branch-a See all the branches
Git branch-r view all remote branches
Git commit-am "Init" to submit and annotate
git remote add origin [email protected]:ndshow
Git push origin master pushes files to the server
Git remote show origin shows the resources in origin
Git push Origin Master:develop
Git push Origin Master:hb-dev associate a local library with a library on the server
git checkout--track origin/dev switch to remote Dev branch
git branch-d master Develop delete local library develop
git checkout-b Dev builds a new local branch dev
Git merge origin/dev Merge branch dev with current branch
git checkout dev switch to local dev branch
Git remote show to view the long-range library
git Add.
git RM file name (including path) removes the specified file from git
git clone git://github.com/schacon/grit.git pull the code down from the server
git config--list See all users
Git ls-files look at the already committed
git rm [file name] Delete a file
Git commit-a commits all changes to the current repos
git add [file name] Add a file to git index
Git commit-v you can see the difference in commit when you use the-v argument
Git commit-m "This is the message describing the commit" adds a commit message
Git Commit-a-A represents add, adds all the change to git index and then commits
Git commit-a-V General commit command
git log to see your commit logs
git diff view updates that have not yet been staged
git rm a.a Remove files (removed from staging area and workspaces)
git rm--cached a.a Remove Files (removed from staging area only)
Git commit-m "Remove" Remove files (removed from git)
Git rm-f a.a forcibly remove modified files (removed from staging area and workspaces)
git diff--cached or git diff--staged view the updates that have not yet been submitted
Git stash push to push files to a temporary space
Git stash pop to pop files from scratch space
---------------------------------------------------------
git remote add origin [email protected]:username/hello-world.git
Git push Origin master submits a local project to the server
-----------------------------------------------------------
Git pull local and server-side synchronization
-----------------------------------------------------------------
git push (remote warehouse name) (branch name) pushes the local branch to the server.
Git push Origin Serverfix:awesomebranch
------------------------------------------------------------------
Git fetch is equivalent to getting the latest version from remote to local, not automatically merge
Git commit-a-M "Log_message" (-A is to commit all changes,-M is to add log information) local modifications are synchronized to the server side:
Git branch branch_0.1 master creates branch_0.1 branch from Master Branch Master
git branch-m branch_0.1 branch_1.0 rename branch_0.1 to branch_1.0
git checkout branch_1.0/master switch to Branch_1.0/master branch
Du-hs

GIT Branch Delete remote branch
git push origin:branch_remote_name
Git branch-r-D branch_remote_name
-----------------------------------------------------------

Initializes the repository and submits it to the remote server side
mkdir WebApp
CD WEBAPP
GIT init local initialization
Touch README
git add README adding files
Git commit-m ' first commit '
git remote add origin [email protected]:d Aixu/webapp.git

Add a remote server side

Two View Remote Warehouse information

View Remote Warehouse information

We can view the details of a remote repository by ordering git remote show [remote-name], for example, to see the cloned Origin repository, which can be run:

$ git Remote Show origin * Remote Origin url:git://github.com/schacon/ticgit.git remote branch merged with ' git pull ' While on Branch master Master tracked remote branches master Ticgit

in addition to the corresponding clone address, it also gives a lot of additional information. It's a friendly way to tell you that if you're in the Master branch, you can use git pull commands to merge the data locally. It also lists all the remote branches that are in the tracking state.

The example above is very simple, and with git in-depth, the information given by Git remote show might look like this:

$ git Remote Show origin * Remote Origin URL: [email protected]:D efunkt/github.git remote Branch merged with ' git pull ' While in branch issues issues remote Branch merged with ' Git pulling ' while on branch master Master New Remote branches (NE XT fetch would store in Remotes/origin) caching Stale tracking branches (use ' git remote prune ') Libwalker Walker2 tracked Remote branches ACL apiv2 dashboard2 issues master Postgres Local branch pushed with ' git push ' master:master

it tells us what branch is the default push when running Git push (the last two lines). It also shows which remote branches are not synchronized to the local (caching branch on line sixth), which have been synchronized to the local remote branch has been deleted on the remote server (Stale tracking branches the two branches below), and running Git pull will automatically merge which branches (the issues and master branches listed in the first four rows).
deletion and renaming of remote warehouses

in the new version of Git, you can use the GIT remote rename command to modify a remote repository's local short name, such as to change the PB to Paul, so you can run:

$ git remote rename PB paul $ Git remote origin Paul

Note that renaming a remote repository also causes the corresponding branch name to change, and the original Pb/master branch is now Paul/master.

If you encounter a remote repository server migration, or if the original clone image is no longer in use, or if a participant no longer contributes code, you need to remove the remote repository and run the GIT remote RM command:

$ git remote RM Paul $ GIT Remote origin

Three creating a remote warehouse

git clone--bare robbin_site robbin_site.git # Create a version-only warehouse with a versioned project
Scp-r my_project.git [Email protected]:~ # Upload the repository to the server

mkdir robbin_site.git && cd robbin_site.git && git--bare init # Create a pure warehouse on the server
git remote add origin [e-mail Protected]:robbin/robbin_site.git # set the repository address
Git push-u Origin Master # client First Commit
Git push-u origin Develop # First submits the local develop branch to the remote develop branch, and the track

git remote Set-head Origin Master # Set the remote repository head to the master branch

IV/ view commit record

git log
git log <file> # View the file for each commit record
git log-p <file> # view diff for each detail change
Git log-p-2 # See a diff of the last two detailed edits
git log--stat # View commit Statistics


Git common command quick check table

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.