Git usage notes, git notes

Source: Internet
Author: User

Git usage notes, git notes

Reprint blog please specify reprint address: http://www.cnblogs.com/lpit/p/4913629.html

Knowledge: Git has a tool called git config that allows you to obtain and set configuration variables. These variables can control the appearance and operations of Git.

1. storage location of configuration files
These variables can be stored in three different locations:
* ** Reference blog http://blog.csdn.net/wirelessqa/article/details/8572928 ***

2. Configure your username and password. The first thing you need to do after installing Git is to set your user name and email address. This is very important because this information is used every time a Git commit is made. It is always embedded in your submission:

1 $ git config --global user.name 'xxxxxxx'  2 $ git config --global user.email 'xxxxxxx@xx.com'
Reapply this setting. You only need to perform this setting once. If you pass the -- global option, Git will always use this information to process all your operations in the system.
If you want to use different names or e-mail addresses in a specific project, you can run the command in the project instead of the -- global option..
1 $ git config user. name 'your username' 2 $ git config user. email 'your mailbox'

 

Git usage
Practice: Create an environment, successfully add, submit, push, update, and other common commands.
1 # environment 2 git -- version 3 git version 1.7.1 4 pwd 5/data1/home/xxxxxxx/img 6 # create a working directory 7 mkdir liupengGitTest 8 cd liupengGitTest/9 # initialize the working directory 10 git init11 # Set the user information of the current version library 12 git config user. name 'xxxxxxxx' 13 git config user. email 'xxxxxxx @ xx.com '14 # test 15 touch README16 # add file 17 git add README 18 # submit the modified file 19 git commit-m'first commit' 20 # add remote repository 21 # remote repository allows you to create 22 git remote add origin ssh on the git service site: // xxxxxxx/mytest. git23 # push local files to remote repository 24 git push-u origin master25 # update the local repository. If you need to modify the file, update it first, preventing conflicts 26 # You can also use git fetch27 git pull

 

 

Git practice advanced

Create branch and merge Branch

  • Create Branch
1 $ pwd 2/data1/home/xxxxxxx/liupengGitTest 3 # view the current branch 4 $ git branch 5 * master 6 # create branch dev, switch the branch to dev 7 # git checkout-B dev. You can use git branch dev in another way; git checkout dev 8 $ git checkout-B dev 9 Switched to a new branch 'dev' 10 $ git branch 11 * dev12 master13 $ ll14 total 415-rw-r -- 1 xxxxxxx domain ^ users 110 Sep 1 README

 

  • Merge Branch
1 $ git branch 2 * dev 3 master 4 $ touch addtxt 5 $ git add addtxt 6 $ git commit-m' branch dev add a new file '7 [dev 78dd0f9] branch dev add a new file 8 0 files changed, 0 insertions (+), 0 deletions (-) 9 create mode 100644 addtxt10 $ git status11 # On branch dev12 nothing to commit (working directory clean) 13 # dev branch two files 14 $ ll15 total 416-rw-r -- 1 xxxxxxx domain ^ users 0 Sep 1 addtxt 17-rw-r -- 1 xxxxxxx domain ^ users 110 Sep 1 README18 $ git checkout master19 Switched to branch 'master' 20 # master branch a file 21 $ ll22 total 423- rw-r -- 1 xxxxxxx domain ^ users 110 Sep 1 README24 # merge Branch 25 $ git merge dev26 Updating a279cb0 .. 78dd0f927 Fast-forward28 0 files changed, 0 insertions (+), 0 deletions (-) 29 create mode 100644 addtxt30 $ git branch31 dev32 * master33 # master points Two files are supported! 34 $ ll35 total 436-rw-r -- 1 xxxxxxx domain ^ users 0 Sep 1 31 addtxt37-rw-r -- 1 xxxxxxx domain ^ users 110 Sep 1 01 README38 # push to remote server git push origin master do not u, if the current branch has a tracing relationship with multiple hosts, you can use the-u option to specify a default host. In this way, you can use git push without adding any parameters. 39 $ git push-u origin master40 Counting objects: 4, done.41 Compressing objects: 100% (2/2), done.42 Writing objects: 100% (3/3), 275 bytes, done.43 Total 3 (delta 0), reused 0 (delta 0) 44 To ssh: // xxxxxxx/mytest. git45 a279cb0 .. 78dd0f9 master-> master46 Branch master set up to track remote branch master from origin.47 $ git status48 # On branch master49 nothing to commit (working directory clean) 50 $

Reprint blog please specify reprint address: http://www.cnblogs.com/lpit/p/4913629.html

 

 

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.