GitHub practice series ~ 1. Environment deployment + create the first file 2015-12-9,

Source: Internet
Author: User

GitHub practice series ~ 1. Environment deployment + create the first file 2015-12-9,

 

Installation series:

Download: http://git-scm.com/download/

Environment setup: (relatively simple, see the figure)

The following is the command mode, which requires a little linux BASICS (Linux Basics). Check the details.

1. Let's look at the configurations of git:

Git config
----------------------------------------
Usage: git config [<options>]

Config file location
-- Global use global config file
-- System use system config file
-- Local use repository config file
-F, -- file <file> use given config file
-- Blob <blob-id> read config from given blob object

Action
-- Get value: name [value-regex]
-- Get-all get all values: key [value-regex]
-- Get-regexp get values for regexp: name-regex [value-regex]
-- Get-urlmatch get value specific for the URL: section [. var] URL
-- Replace-all replace all matching variables: name value [value_rege x]
-- Add a new variable: name value
-- Unset remove a variable: name [value-regex]
-- Unset-all remove all matches: name [value-regex]
-- Rename-section rename section: old-name new-name
-- Remove-section remove a section: name
-L, -- list all
-E, -- edit open an editor
-- Get-color find the color configured: slot [default]
-- Get-colorbool find the color setting: slot [stdout-is-tty]

Type
-- Bool value is "true" or "false"
-- Int value is decimal number
-- Bool-or-int value is -- bool or -- int
-- Path value is a path (file or directory name)

Other
-Z, -- null terminate values with NUL byte
-- Name-only show variable names only
-- Includes respect include directives on lookup

----------------------------------------
2. Set the name:


Git config -- global user. name "your name"

3. Set Email:
Git config -- global user. email "your mailbox"

----------------------------------------
4. Set output for more purpose
Git config -- global color. ui auto


5. If you forget your configuration, use this command to view it.


Cat ~ /. Gitconfig

----------------------------------------
[User]
Name = your name
Email = Your mailbox
[Color]
Ui = auto
----------------------------------------
6. Set the SSH Key


Ssh-keygen-t rsa-C "your mailbox"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/DNT_PC/. ssh/id_rsa): Press Enter.
/C/Users/DNT_PC/. ssh/id_rsa already exists.
Overwrite (y/n )? Enter
----------------------------------------
7. Do not remember to use this command for key:

$ Cat ~ /. Ssh/id_rsa.pub
----------------------------------------
Ssh-rsa Secure + LdBit8L3CSltQ6AhgOL8xcUHxR + secure/secure + + secure ************************** secure/secure * ***************
----------------------------------------
8. Add a key (public) to github)


----------------------------------------
9. Verify with your private key and github


Ssh-T git@github.com
----------------------------------------
The authenticity of host 'github. com (192.30.252.128) 'can't be established.
RSA key fingerprint is SHA256: nThbg6k ************************ viKw6E5 ********.
Are you sure you want to continue connecting (yes/no )? Enter yes
Warning: Permanently added 'github. com, 192.30.252.128 '(RSA) to the list of known hosts.
Hi, your name! You 've successfully authenticated, but GitHub does not provide shell access.
----------------------------------------
10. Create a public repository (Private pricing) in github and initialize the repository (the bottom check box is shown below in the two drop-down lists below)


----------------------------------------
11. clone a github repository address. It will be useful later.


----------------------------------------
12. Copy a copy to the local device.

Git clone git@github.com: dunitian/test. git (previous address)

----------------------------------------
Cloning into 'test '...
Warning: Permanently added the RSA host key for IP address '2017. 30.252.131 'to the list of known hosts.
Remote: Counting objects: 3, done.
Remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Grouping objects: 100% (3/3), done.
Checking connectivity... done.
----------------------------------------
13. Write something and test it.


Cd test(Project name, case sensitive)

DNT_PC @ DNT_PC-PC MINGW32 ~ /Test (master)
Ls(View what is in the current directory)
README. md

DNT_PC @ DNT_PC-PC MINGW32 ~ /Test (master)
Vi dnt.txt(If a dnt.txt file is opened, a dnt.txt file is created if no dnt.txt file is created)

Enter what you want to write, I enter edit mode, Press esc enter: wq and press enter to save
----------------------------------------
14. Check the git status (untracked files status is not submitted)


Git status
----------------------------------------
On branch master
Your branch is up-to-date with 'origin/Master '.
Untracked files:
(Use "git add <file>..." to include in what will be committed)

Dnt.txt

Nothing added to commit but untracked files present (use "git add" to track)
----------------------------------------
15. Submit the file to the repository


Git add dnt.txt (added to the temporary storage zone)

Git commit-m "add first file to my git" (submit; comment in quotation marks)
----------------------------------------
[Master 4e69105] add first file to my git
Warning: LF will be replaced by CRLF in dnt.txt.
The file will have its original line endings in your working directory.
1 file changed, 1 insertion (+)
Create mode 100644 dnt.txt
----------------------------------------
16. Go to github and check that at this time, we found that we have added our files (Don't Be Afraid)


----------------------------------------
17. view the submitted diary (scared to death, hurry to check the log)


Git log
----------------------------------------
Commit 4e6910512df341e6d71d83607df8f44a6bd5a5b6
Author: dunitian <1054186320@qq.com>
Date: Wed Dec 9 22:26:44 2015 + 0800

Add first file to my git

Commit 6f4fa43de0619c34345fb65d1b32ed887d4efd04
Author: dunitian <1054186320@qq.com>
Date: Wed Dec 9 21:30:07 2015 + 0800

Initial commit
----------------------------------------
18. I used to push it and update github. (If you find a problem such as command not found, enter it again)


Git push
----------------------------------------
Warning: push. default is unset; its implicit value has changed in
Git 2.0 from 'matching 'to 'simple'. To squelch this message
And maintain the traditional behavior, use:

Git config -- global push. default matching

To squelch this message and adopt the new behavior now, use:

Git config -- global push. default simple

When push. default is set to 'matching ', git will push local branches
To the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
Behavior, which only pushes the current branch to the corresponding
Remote branch that 'git pull 'uses to update the current branch.

See 'git help config' and search for 'Push. default' for further information.
(The 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'Stream' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 294 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com: dunitian/test. git
6f4fa43 .. 4e69105 master-> master
----------------------------------------

Close, daughter-in-law urged .... Continue tomorrow

 

Summary:

------------ Set ---------------- 01. set the name to git config -- global user. name "Your name" 02. set Email: git config -- global user. email "your mailbox" 03. set git config -- global color. ui auto04. set SSH Keyssh-keygen-t rsa-C "your mailbox" ------------ basics ---------------- 05. clone a copy to local git clone git@github.com: dunitian/test. git (ssh Project address) 06. submit the file to the repository git add dnt.txt (add to the staging area) git commit-m "comment" (submit) 07. push it, update githubgit push ------------ view ----- ------------- 08. view your configuration cat ~ /. Gitconfig09. view keycat ~ /. Ssh/id_rsa.pub10. view the git status git status11. view the commit diary git log ------------ others ------------------

  

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.