Git learning--personal frequently used commands add,commit and push

Source: Internet
Author: User

git command line configuration
1 Installing GitHub
2 Installing Msysgit
3 To configure the user name and fuel tank
git config--global user.name < username >
My command is: git config--global user.name Mchdbagh
git config--global user.email < tank >
My command is: git config--global [email protected]
4 Verifying that there is no remote server connected
ssh-t [email protected]


5 to generate SSH key
$ ssh-keygen
If you see a password, you can return to the main window with a direct 2 enter.

Go find. SSH inside the id_isa.pub open, it is best to open with notepad++, the contents of the inside copy out, and then put in the https://URL inside, join
See the documentation for more information on how to build. Http://www.worldhello.net/gotgithub/index.html#id6

Git Common Commands Introduction
Git init-initializes the project and uses it when it starts initializing the project
git clone--cloning from the server to the local, if the server already has a project, directly using this command clone to local use.
Git status--view version information
Git add--Add a local file
Git commit--Commit changes
git push--tags--push changes to the server


(1) Git init operation

[HTML]View Plaincopyprint?
    1. [Email protected] ~
    2. mkdir Test_git
    3. [Email protected] ~
    4. CD test_git/
    5. [Email protected] ~/test_git
    6. Ls
    7. [Email protected] ~/test_git
    8. $ git init
    9. Initialized empty Git repository in C:/Documents and settings/skyman/test_git/.git/
    10. Ls-a
    11. .. . git


See A. git file

[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 Skyman administ 0 Sep 25 23:10..
    5. Drwxr-xr-x 1 skyman administ 0 Sep 23:10. git
    6. $



See more of the other. Git directory, indicating that the project was created successfully.


(2) Git clone operation
Login https://github.com/, look at the bottom right corner, find the URL to open the library to add the hint mchdbagh/manual56 to the back, the URL is https://github.com/mchdbagh/manual56



After opening, click the Copy button below 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 choose SSH mode: [Email protected]:mchdbagh/manual56.git

git clone [email protected]:mchdbagh/manual56.git;


Open git clone [email protected]:mchdbagh/helloworld.git
If you need to customize a directory name, you can write git clone [email protected]:mchdbagh/helloworld.git TEST_HW


Detect if clone succeeds, see if 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 Documents recent WINDOWS HelloWorld test_git



(3) GIT add operation experiment

[Plain]View Plaincopyprint?
  1. $ CD manual56/
  2. --View the status of git current repository
  3. $ git status
  4. # on Branch Master
  5. Nothing-to-commit (working directory clean)
  6. --Go to the chapter directory I want to edit
  7. $ CD docs/chapter_17/
  8. $ vim 17.5.0.0.0.md--Create a new MD file, which simply writes "Only a Test" string, Wq save exit Edit state.
  9. --View status
  10. $ git status
  11. # on Branch Master
  12. # untracked Files:
  13. # (use "git add <file> ..." to include in what'll be committed)
  14. #
  15. # 17.5.0.0.0.MD--See a new file with red color has not been submitted, the name of this line is shown in red.
  16. Nothing added to commits but untracked files present (use "Git add" to track)

Adding files Add

Git add 17.5.0.0.0.md adds a single file, multiple files can be separated by spaces, such as (git add 17.5.0.0.0.md 17.5.0.0.1.md 17.5.0.0.2.md), or you can use Git add-a to add all the files.

[JavaScript]View Plaincopyprint?
  1. --Execute Add command
  2. $ git Add 17.5.0.0.0.md
  3. --View individual file version status
  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 entire library version status
  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 open C:\Documents and settings\skyman\manual56\docs\chapter_17\17.5.0.0.0.md with Markdownpad, enter the Chinese string inside, save exit. Then check the repository status, show the green color of the expression has been cached, the red color is modified but not cached.

[HTML]View Plaincopyprint?

(4) Git commit, after the modification, commit to commit git commit-m "Test change",-M is the specified submission information, required items

[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. --Display has been submitted to the local repository

(5) Push the modified file to the server, git push--tags --push so cache the file to 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 (delta 6), reused 0 (Delta 0)
    7. to [email protected]:mchdbagh/manual56.git
    8. E754e68. 3e96f90 Master-> Master



OK success, and then open the URL https://github.com/xxxxxx/blob/master/docs/Chapter_17/17.5.0.0.0.md to see the new content submitted, see the picture shows, The newly created file 17.5.0.0.0.md has been successfully uploaded to the remote file server.

These projects, if they are individual projects, are sufficient to meet our daily use requirements, but if more people work together, that is not enough.

Git learning--personal frequently used commands add,commit and push

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.