How to use git simple and branch management under Windows

Source: Internet
Author: User
Tags git client how to use git using git sourcetree

Simple use of Git on Windows

Git client installation (slightly)

1) Generate SSH key:

$ ssh-keygen -t rsa -c  "[email protected]"  generating public/private rsa key pair. enter file in which  to save the key  (/c/users/bunny/.ssh/id_rsa): created directory  '/c/ Users/bunny/.ssh ' . enter passphrase  (empty for no passphrase): Enter  same passphrase again: your identification has been saved in /c/ users/bunny/.ssh/id_rsa. your public key has been saved in /c/users/ Bunny/.ssh/id_rsa.pub. the key fingerprint is: 74:6e:f3:14:0a:95:c3:d8:8e:50:62:b3:b2 : 79:45:4d [email protected][email protected] /e/gittest 

Copy the generated public key file Id_rsa.pub content to the Gitlab admin interface under SSH keys:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/5A/wKiom1TQfW-Tb1orAAIvvEiOjh8119.jpg "title=" 90.png "alt=" Wkiom1tqfw-tb1oraaivveiojh8119.jpg "/>

2) from the server clone a copy of project to test

$ git clone [email protected]:bunny/com-gittest.git  Cloning into  ' com-gittest ' ... the authenticity of host  ' git.olymtech.com  (183.131.76.44) '  can ' t be established . rsa key  Fingerprint is db:af:31:f4:1c:3f:38:39:48:84:24:ac:08:34:ad:bc. are you sure you  want to continue connecting  (yes/no)? yes warning: permanently  added  ' git.olymtech.com,183.131.76.44 '   (RSA)  to the list of known  Hosts. warning: you appear to have cloned an empty repository.  checking connectivity... done. 
$ cd com-gittest/ $ git init reinitialized existing git  Repository in e:/gittest/com-gittest/.git/ [email protected] /e/gittest/com-gittest   (Master)  $ touch README[email protected] /E/gittest/com-gittest  (master)  $ git add README [email protected] /E/gittest/com-gittest  (Master)  $ git commit -m  ' First commit test '  [master  (root-commit)   9c37bb4] first commit test 1 file changed, 0 insertions (+),  0  deletions (-)  create mode 100644 readme [email protected] /e/gittest/ com-gittest  (Master)  $ git remote add origin [email protected]:bunny/ Com-gittest.git fatal: remote origin already exists. [email protected]  /E/gittest/com-gittest  (MASter)  $ git push -u origin master counting objects: 3, done.  Writing objects: 100%  (3/3),  206 bytes | 0 bytes/s, done.  Total 3  (delta 0), reused 0  (delta 0)  To [email  Protected]:bunny/com-gittest.git * [new branch] master -> master branch  master set up to track remote branch master from origin.


Graphical interface git branch management how to use

git client using sourcetree (install a little, install mercurial client is ignored ),/http/ www.sourcetreeapp.com/download/

1. Use Git's own GIT Branch branch management command:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/5A/wKiom1TQeLXxpkLXAARTnQCVH14065.jpg "title=" 15.png "alt=" Wkiom1tqelxxpklxaartnqcvh14065.jpg "/>

To create a new branch and push:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/5A/wKiom1TQeNyijC-tAAO-etJh2jY430.jpg "title=" 16.png "alt=" Wkiom1tqenyijc-taao-etjh2jy430.jpg "/>

Find a machine clone down to verify branch OK:

[email protected]:/tmp$ git cloneHttp://git.olymtech.com/bunny/com-gittest.git
Cloning into ' com-gittest ' ...
Username for 'http://git.olymtech.com': Bunny
Password for 'Http://bunny@git. Olymtech.com ':
Remote:counting Objects:3, done.
Remote:total 3 (Delta 0), reused 0 (Delta 0)
Unpacking objects:100% (3/3), done.
Checking connectivity ... done.

[email protected] :/tmp/com-gittest$ git branch-r
Origin/head-Origin/master
Origin/b_dev
Origin/b_release
Origin/master


2. Use git flow to simplify branch management:

Git flow initialize the repository (using the default branch):

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/56/wKioL1TQegviWK3FAAQyZ1ROBKU748.jpg "title=" 17.png "alt=" wkiol1tqegviwk3faaqyz1robku748.jpg "/> initialization completes to see the newly established branch name pushed to the server side:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/56/wKioL1TQei2STLM5AALT_hePVmc731.jpg "title=" 18.png "alt=" Wkiol1tqei2stlm5aalt_hepvmc731.jpg "/>

Find a client machine to verify the service side branch:

[email protected] :/tmp$ git clone Http://git.olymtech.com/bunny/com-bunnytest.git

[email protected] :/tmp/com-bunnytest$ git branch-r
Origin/head-Origin/master
Origin/develop
Origin/master


Git branch without parameters: Lists the branches that already exist locally

git branch-r lists remote branches

git branch-a lists local and remote branches

Git branch creates a new local branch, and you need to be aware that this is just a branch, not a branch switch, for example:
#git Branch NEWBRANCH2

git checkout newbranch2 switch to the newly created branch

Git checkout master switches back to the main branch

Git branch-m | -M oldbranch newbranch Rename the branch, if the Newbranch name branch already exists, you need to use-m to force the rename, otherwise, use-M to rename.

Git branch-d | -D branchname Delete Branchname Branch

Git branch-d-R branchname Remove remote Branchname Branch


Additional notes:

Git flow defines the following branches

Main Branch

1. Master: Always in Production-ready state

2.develop: Latest Next release development status J

Supportive Branch

1. Feature branches: The development of new functions from the develop sub-expenditure, the completion of the merge back develop

2. Release branches: Ready to release the version, only repair bugs. From develop, complete the merge back to master and develop

3. Hotfix branches: Can't wait for release version to fix master online immediately. Will be spent from master, and then merge back to master and develop

http://blog.csdn.net/menxu_work/article/details/12494903



git If you need to branch management, two ways:
1. Locally set up the branch to the server, if not troubleshooting permissions or use of the problem.

Git Bash+egit in the project with the use of the most commonly used method summary, can refer to this blog writing very detailed

http://blog.csdn.net/hongshan50/article/details/22582049


2. Using git flow (a conventional development specification), Sourcetree tools: both Gitbash command line and Egit graphical management have a git flow options feature

This article is from the "E-space" blog, please be sure to keep this source http://iceeggplant.blog.51cto.com/1446843/1611148

How to use git simple and branch management under Windows

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.