Installation and use of Git under Windows

Source: Internet
Author: User
Tags commit diff git clone git commands

Git what is a thing, I do not introduce here, if we still do not understand, you can go to Baidu. I'm here to give an introduction to the URL: Git profile here is leaving an address

If you do not install the package, you can also download here: Click to download the link address:

I will not introduce the installation process, direct Click Next Next on the line. If you do not want a fool-like installation, you are prompted to install. We recommend that you do not install all the software system disk, C disk below.

After the installation is complete, we run it. For the first time, you don't know how to do it, you can enter GIT commands, or git help commands or git help-a help-g commands to see what the GIT provides. The following figure:

Here is only a screenshot of some of the commands.

Let's take a look at the warehouse command: Git show

There is no warehouse here, we first use, no warehouse. We use the command git init or use git init-db to create an empty warehouse. Generates a subdirectory of. Git in the current directory. Later, all file change information will be saved to this directory. See Effect screenshot:

$ git show
fatal:bad default revision ' head '

There is a problem with the header version here.

Add some common commands below.

1 Remote Warehouse related command

Checkout warehouse: $ git clone 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


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:// 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





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@
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:// 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 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

mkdir WebApp
Git init
git add README
Git commit-m ' a '
Git remote add Origin
Git push-u Origin MasterGit Common Command chart

The above written half, found online someone summed up very well, directly copy over. URL:

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.