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?
- Kyman @ SKYMAN-CF7E3587 ~
- Mkdir test_git
- Kyman @ SKYMAN-CF7E3587 ~
- Cd test_git/
- Kyman @ SKYMAN-CF7E3587 ~ /Test_git
- Ls
- Kyman @ SKYMAN-CF7E3587 ~ /Test_git
- $ Git init
- Initialized empty Git repository in c:/Documents and Settings/skyman/test_git/. git/
- Ls-
- ... Git
The. git file is displayed.
[Plain]View plaincopyprint?
- $ Ls-al
- Total 0
- Drwxr-xr-x 3 skyman Administ 0 Sep 25 23: 10.
- Drwxr-xr-x 41 skyman Administ 0 Sep 25 23:10 ..
- Drwxr-xr-x 1 skyman Administ 0 Sep 25 23:10. git
- $
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?
- $ Ls
- AppData Favorites NTUSER. DAT SendTo _ viminfo manual56 wc
- Application Data IECompatCache NetHood Templates admovie.jpg ntuser. dat. LOG ??????????????????
- CMB IETldCache PrintHood UserData client. log ntuser. ini ??????
- Contacts Local Settings PrivacIE VirtualBox VMs extensions ntuserdirect_MyManager.dat
- Cookies My clients Recent WINDOWS helloworld test_git
(3) git add operation experiment
[Plain]View plaincopyprint?
- $ Cd manual56/
- -- View the status of the current git version Library
- $ Git status
- # On branch master
- Nothing to commit (working directory clean)
- -- Go to the chapter directory that I want to modify
- $ Cd docs/Chapter_17/
- $ 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.
- -- View status
- $ Git status
- # On branch master
- # Untracked files:
- # (Use "git add <file>..." to include in what will be committed)
- #
- # 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.
- 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?
- -- Execute the Add command
- $ Git add 17.5.0.0.0.md
- -- View the version status of a single file
- $ Git status 17.5.0.0.0.md
- # On branch master
- # Changes to be committed:
- # (Use "git reset HEAD <file>..." to unstage)
- #
- # New file: 17.5.0.0.0.md
- #
- -- View the status of the entire database version
- $ Git status
- # On branch master
- # Changes to be committed:
- # (Use "git reset HEAD <file>..." to unstage)
- #
- # New file: 17.5.0.0.0.md
- #
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?
- $ Git commit-am "Test chanage"
- [Master 3e96f90] Test chanage
- 1 file changed, 1 insertion (+), 1 deletion (-)
- $ Git status
- # On branch master
- # Your branch is ahead of 'origin/master' by 2 commits.
- #
- Nothing to commit (working directory clean)
- -- 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?
- $ Git push origin master
- Counting objects: 13, done.
- Delta compression using up to 2 threads.
- Compressing objects: 100% (8/8), done.
- Writing objects: 100% (10/10), 768 bytes, done.
- Total 10 (delta 6), reused 0 (delta 0)
- To git@github.com: mchdbagh/manual56.git
- 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.