Git distributed version control system

Source: Internet
Author: User
Tags diff version control system git clone

Absrtact: Git management mining Map, a more comprehensive view of the workflow of Git, due to Web page display restrictions, it is recommended to download a larger view.

Git Common Commands

Git is a very powerful distributed version control system. It is not only suitable for managing the source code of large open source software, but also has many advantages in managing private documents and source code.

Git Common Operations Command:

1 Remote Warehouse related command

Checkout warehouse: $ git clone git://github.com/jquery/jquery.git

View remote warehouses: $ git remote-v

Add remote warehouse: $ git remote add [name] [url]

Delete Remote warehouse: $ git remote RM [name]

Modify Remote warehouse: $ git remote set-url--push [name] [Newurl]

Pull remote warehouse: $ git pull [remotename] [Localbranchname]

Push remote warehouse: $ git push [remotename] [Localbranchname]

* If you want to submit a local branch test to a remote repository and serve as the master branch of a remote repository, or as a branch of another named Test, the following:

$git Push Origin Test:master//submit local Test branch as remote Master Branch

$git Push Origin test:test//submit local test branch as remote Test branch

2) Branch (branch) operations related command

View local branch: $ git Branch

View Remote branch: $ git branch-r

Create local branch: $ git branch [name]----Note the new branch is not automatically switched to the current branch when it is created

Toggle Branch: $ git checkout [name]

Create a new branch and immediately switch to the new branch: $ git checkout-b [name]

Delete Branch: $ git branch-d [name]-----the D option deletes only those branches that are already participating in the merge, and cannot be deleted for branches that do not have a merge. If you want to force the deletion of a branch, you can use the-D option

Merge branch: $ git merge [name]----Merge a branch with name [name] with the current branch

To create a remote branch (local branch push to remote): $ Git push origin [name]

Delete Remote branch: $ git push origin:heads/[name] or $ gitpush origin: [Name]

* Create an empty branch: (Remember to submit your current branch modification before executing the command, otherwise it will be forced to delete the clean without regret)

$git symbolic-ref Head Refs/heads/[name]

$rm. Git/index

$git CLEAN-FDX

3) version (tag) operation related command

View version: $ git tag

Create version: $ git tag [name]

Delete version: $ git tag-d [name]

View remote version: $ git tag-r

To create a remote version (local version push to remote): $ Git push origin [name]

Delete Remote version: $ git push origin:refs/tags/[name]

To merge a remote warehouse tag to local: $ Git pull Origin--tags

Upload local tag to remote warehouse: $ GIT push origin--tags

Create annotated tag:$ git tag-a [name]-M ' YourMessage '

4) Sub-module (submodule) Related Operation command

Add Child module: $ git submodule add [url] [path]

such as: $git submodule add Git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs

Initialize the child module: $ git submodule init----Only run once when the warehouse is first checked out

Update Sub module: $ git submodule update----need to run every time you update or switch a branch

To delete a child module: (4 steps away OH)

1) $ git RM--cached [path]

2 Edit ". Gitmodules" file, delete the related configuration node of the child module

3 edit ". Git/config" file, delete the related configuration node of the child module

4 Manually delete the child module residue directory

5 Ignore some files, folders do not submit

Create a file with the name ". Gitignore" under the warehouse root, write the unwanted folder name or file, and take one row for each element, such as

Target

Bin

*.db

=====================

Git Common Commands

Git branch view all local branches

Git Status View current status

Git commit Commit

Git branch-a View all branches

Git branch-r View all local branches

Git commit-am "Init" to submit and annotate

Git remote add Origin git@192.168.1.119: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 associates a local library with a library on a server

git checkout--track origin/dev switch to remote Dev branch

git branch-d Master Develop delete local libraries develop

git checkout-b Dev builds a new local branch dev

Git merge Origin/dev merges branch Dev with the current branch

git checkout dev switch to local dev branch

Git remote show look at the distant library

git Add.

git rm filename (including path) deletes the specified file from git

git clone git://github.com/schacon/grit.git to pull code from the server

git config--list See all users

Git ls-files look has been submitted by the

git rm [file name] Deletes a file

Git commit-a commits all changes to the current repos

git add [file name] Adds a file to git index

Git commit-v you can see the difference between a commit when you use the-v argument

Git commit-m "This are the message describing the commit" add a Commit

Git commit-a-A is representing add, adding all the change to git index and then commits

Git commit-a-V General Submit command

git log to see your commit

git diff view updates that have not been staged

git rm a.a Remove files (removed from registers and workspaces)

git rm--cached a.a Remove file (only remove from registers)

git commit-m Remove file (remove from Git)

Git rm-f a.a forcibly removes modified files (removed from registers and workspaces)

Git diff--cached or $ git diff--staged view updates that have not yet been submitted

Git stash push to push the file to a temporary space

git stash pops down files from temporary space

---------------------------------------------------------

Git remote add Origin git@github.com:username/hello-world.git

Git push Origin master submits the 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 the remote to the local, not automatically merge

Git commit-a-M "Log_message" (-A is to commit all changes,------------log information is added) local modifications 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


-----------------------------------------------------------

mkdir WebApp

CD WEBAPP

Git init

Touch README

git add README

Git commit-m ' a '

Git remote add Origin git@github.com:daixu/webapp.git

Git push-u Origin Master


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.