Git learning, git learning tutorial

Source: Internet
Author: User

Git learning, git learning tutorial

Git command line configuration
1 install Github
2. Install msysgit
3. Configure the user name and Fuel Tank
Git config -- global user. name <user name>
My command is: git config -- global user. name mchdbagh
Git config -- global user. email <fuel tank>
My command is: git config -- global mchdba@yahoo.com
4. Check whether the remote server is connected.
Ssh-T git@github.com


5. generate an ssh key
$ Ssh-keygen
If you need to enter the password, you can directly return to the main window with two enter keys.

Go to id_isa.pub in. ssh to open it. It is best to use notepad ++ to copy the content in it and put it in the https: // URL.
For more information about how to generate the SDK, see the document. Http://www.worldhello.net/gotgithub/index.html#id6

Git Common commands
Git init -- initialize the project, which is used at the beginning of Project Initialization
Git clone-clone from the server to the local machine. If a project already exists on the server, use this command to clone it to the local machine for use.
Git status -- View version information
Git add -- add local files
Git commit -- submit changes
Git push -- tags -- push changes to the server


(1) git init operation

[Html]View plaincopyprint?
  1. Kyman @ SKYMAN-CF7E3587 ~
  2. Mkdir test_git
  3. Kyman @ SKYMAN-CF7E3587 ~
  4. Cd test_git/
  5. Kyman @ SKYMAN-CF7E3587 ~ /Test_git
  6. Ls
  7. Kyman @ SKYMAN-CF7E3587 ~ /Test_git
  8. $ Git init
  9. Initialized empty Git repository in c:/Documents and Settings/skyman/test_git/. git/
  10. Ls-
  11. ... Git


The. git file is displayed.

 

[Plain]View plaincopyprint?
  1. $ Ls-al
  2. Total 0
  3. Drwxr-xr-x 3 skyman Administ 0 Sep 25 23: 10.
  4. Drwxr-xr-x 41 skyman Administ 0 Sep 25 23:10 ..
  5. Drwxr-xr-x 1 skyman Administ 0 Sep 25 23:10. git
  6. $



 

 

If you see another. git directory, the project is successfully created.


(2) git clone operation
Log on to the terminal



After opening, click the copy button under the HTTPS clone URL column in the lower right corner to get the clone address https://github.com/mchdbagh/manual56.git of the library,

You can also select the ssh mode: git@github.com: mchdbagh/manual56.git

Git clone git@github.com: mchdbagh/manual56.git;


Open git clone git@github.com: mchdbagh/helloworld. git
To customize a directory name, you can write it as git clone git@github.com: mchdbagh/helloworld. git test_hw


Check whether the clone is successful. Check whether the manual56 directory exists.

 

[Java]View plaincopyprint?
  1. $ Ls
  2. AppData Favorites NTUSER. DAT SendTo _ viminfo manual56 wc
  3. Application Data IECompatCache NetHood Templates admovie.jpg ntuser. dat. LOG ??????????????????
  4. CMB IETldCache PrintHood UserData client. log ntuser. ini ??????
  5. Contacts Local Settings PrivacIE VirtualBox VMs extensions ntuserdirect_MyManager.dat
  6. Cookies My clients Recent WINDOWS helloworld test_git



 

(3) git add operation experiment

 

[Plain]View plaincopyprint?
  1. $ Cd manual56/
  2. -- View the status of the current git version Library
  3. $ Git status
  4. # On branch master
  5. Nothing to commit (working directory clean)
  6. -- Go to the chapter directory that I want to modify
  7. $ Cd docs/Chapter_17/
  8. $ Vim 17.5.0.0.0.md -- create a new md file with the "only a test" string written in it. wq is saved and edited.
  9. -- View status
  10. $ Git status
  11. # On branch master
  12. # Untracked files:
  13. # (Use "git add <file>..." to include in what will be committed)
  14. #
  15. # 17.5.0.0.0.md -- a new file with a red color has not been submitted, and the file name of this row is displayed in red.
  16. Nothing added to commit but untracked files present (use "git add" to track)

 

Add File

Git add 17.5.0.0.0.md to add A single file. Multiple files can be separated by spaces. For example, (git add 17.5.0.0.0.md 17.5.0.0.1.md 17.5.0.0.2.md), you can also use git add-A to add all files.

 

[Javascript]View plaincopyprint?
  1. -- Execute the Add command
  2. $ Git add 17.5.0.0.0.md
  3. -- View the version status of a single file
  4. $ Git status 17.5.0.0.0.md
  5. # On branch master
  6. # Changes to be committed:
  7. # (Use "git reset HEAD <file>..." to unstage)
  8. #
  9. # New file: 17.5.0.0.0.md
  10. #
  11. -- View the status of the entire database version
  12. $ Git status
  13. # On branch master
  14. # Changes to be committed:
  15. # (Use "git reset HEAD <file>..." to unstage)
  16. #
  17. # New file: 17.5.0.0.0.md
  18. #



 

 

Manually use MarkdownPad to Open C: \ Documents and Settings \ skyman \ manual56 \ docs \ Chapter_17 \ 17.5.0.0.0.md, enter a Chinese string in it, and save and exit. Check the version database status. The green color indicates that the database has been cached. The red color indicates that the database has been modified but not cached.

 

[Html]View plaincopyprint?

(4) git commit. After modification, submit the commit.Git commit-m "Test change",-m indicates the submission information, required project

[Html]View plaincopyprint?
  1. $ Git commit-am "Test chanage"
  2. [Master 3e96f90] Test chanage
  3. 1 file changed, 1 insertion (+), 1 deletion (-)
  4. $ Git status
  5. # On branch master
  6. # Your branch is ahead of 'origin/master' by 2 commits.
  7. #
  8. Nothing to commit (working directory clean)
  9. -- It indicates that the database has been submitted to the local version library.

 

(5) push modified files to the server, git push -- tags-- Push: the files cached on the local server.

 

[Html]View plaincopyprint?
  1. $ Git push origin master
  2. Counting objects: 13, done.
  3. Delta compression using up to 2 threads.
  4. Compressing objects: 100% (8/8), done.
  5. Writing objects: 100% (10/10), 768 bytes, done.
  6. Total 10 (delta 6), reused 0 (delta 0)
  7. To git@github.com: mchdbagh/manual56.git
  8. E754e68... 3e96f90 master-> master



 

 

OK.

 

 

 

For personal projects, these projects are enough to meet our daily usage requirements, but it is far from enough if many people work together.

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.