1. Git Common commands: Fast query gitbranch view all local branches gitstatus view current status gitcommit submit gitbranch-a view all branches gitbranch-r view all remote branches gitcommit-am & quot; init & quot; submit and add comments to gitremote
I. Quick query of common Git commands
Git branch: view all local branches
Git status to view the current status
Git commit submit
Git branch-a view all branches
Git branch-r view all remote branches
Git commit-am "init" Submit and add comments
Git remote add origin git@192.168.1.119: ndshow
Git push origin master to push the file to the server
Git remote show origin displays Resources in the remote library origin
Git push origin master: develop
Git push origin master: hb-dev associate the local database with the database on the server
Git checkout -- track origin/dev switch to remote dev Branch
Git branch-D master develop Delete local database develop
Git checkout-B dev creates a new local branch dev
Git merge origin/dev combines the dev branch with the current Branch
Switch git checkout dev to the local dev Branch
Git remote show to view remote Libraries
Git add.
Git rm file name (including path) delete specified file from git
Git clone git: // github.com/schacon/grit.git pulls the code from the server
Git config -- list to view all users
Git ls-files to view submitted
Git rm [file name] delete an object
Git commit-a submits all changes to the current repos
Git add [file name] add a file to git index
Git commit-v: when you use the-v parameter, you can see the difference between commit.
Git commit-m "This is the message describing the commit" add commit Information
Git commit-a indicates add. add all the changes to the git index and then commit.
Git commit-a-v General commit command
Git log to view your commit log
View unsaved updates in git diff
Git rm a. a. Remove files (from the temporary storage zone and workspace)
Git rm -- cached a. a: Remove files (only deleted from the temporary storage zone)
Git commit-m "remove" remove files (delete from Git)
Git rm-f a. a forcibly remove the modified file (deleted from the temporary storage zone and workspace)
Git diff -- cached or $ git diff -- staged to view uncommitted updates
Git stash push pushes files to a temporary space
Git stash pop: pop the file from the temporary space
---------------------------------------------------------
Git remote add origin git@github.com: username/Hello-World.git
Git push origin master to submit local project to server
-----------------------------------------------------------
Local synchronization between git pull and Server
-----------------------------------------------------------------
Git push (Remote repository name) pushes local branches to the server.
Git push origin serverfix: awesomebranch
------------------------------------------------------------------
Git fetch is equivalent to obtaining the latest version from a remote device to the local device, and does not automatically merge
Git commit-a-m "log_message" (-a is to submit all changes,-m is to add log information) Local modifications are synchronized to the server:
Git branch branch_0.1 master creates branch_0.1 branch from 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
-----------------------------------------------------------
Initialize the version library and submit it to the remote server.
Mkdir WebApp
Cd WebApp
Git init local initialization
Touch README
Git add README add File
Git commit-m'first commit'
Git remote add origin git@github.com: daixu/WebApp. git
Add a remote server
2. view remote warehouse Information
View remote Repository Information
Run the git remote show [remote-name] command to view details of a remote repository. For example, to view the cloned origin repository, run:
$ Git remote show origin * remote origin URL: git: // github.com/schacon/ticgit.git Remote branch merged with 'git pull 'while on branch master Tracked remote branches master ticgit
In addition to the corresponding clone address, it also provides a lot of additional information. It kindly tells you that if it is in the master branch, you can use the git pull command to capture data and merge it locally. All remote branches in the tracking status are also listed.
The above example is very simple, and with the deepening of Git, the information provided by git remote show may look like this:
$ Git remote show origin * remote origin URL: git@github.com: defunkt/github. git Remote branch merged with 'git pull 'while on branch issues Remote branch merged with 'git pull' while on branch master New remote branches (next fetch will store in remotes/origin) caching Stale tracking branches (use 'git remote prune ') libwalker walker2 Tracked remote branches acl apiv2 dashboard2 issues master ipvs Local branch pushed with 'git push' master: master
It tells us what the default push branch is when running git push ). It also shows which remote branches have not been synchronized to the local database ), which remote branches have been synchronized to the local server have been deleted on the remote server, and which branches will be automatically merged when running git pull: issues and master branches listed in the first four rows ).
Delete and rename a remote Repository
In the new version of Git, you can use the git remote rename command to modify the brief name of a remote repository locally. For example, to change pb to paul, run the following command:
$ Git remote rename pb paul $ git remote origin paul
Note that renaming a remote Repository also changes the name of the corresponding branch. The original pb/master branch is now paul/master.
When a remote repository server is migrated, the original cloned image is no longer used, or a participant no longer contributes code, you need to remove the corresponding remote repository and run the git remote rm command:
$ Git remote rm paul $ git remote origin
3.Create a remote Repository
Git clone -- bare robbin_site robbin_site.git # use a project with a version to create a version-only Repository
Scp-r my_project.git git@git.csdn.net :~ # Upload a pure repository to the server
Mkdir robbin_site.git & cd robbin_site.git & git -- bare init # create a pure repository on the server
Git remote add origin git@github.com: robbin/robbin_site.git # Set remote repository address
Git push-u origin master # first client commit
Git push-u origin develop # submit the local develop branch to the remote develop branch for the first time, and track
Git remote set-head origin master # set the HEAD of the remote warehouse to point to the master Branch
4/View submission records
Git log
Git log # View each submission record of the file
Git log-p # View the diff of each detailed Modification
Git log-p-2 # view the diff of the last two detailed changes
Git log -- stat # view submitted statistics