Git Learning Summary

Source: Internet
Author: User

1.GIt has been installed under the Linux operating system without having to install it again. Installation is required under the Windows operating system,

This part is reproduced from http://www.cnblogs.com/monodin/p/3268679.html

Msysgit is a git for Windows version with the home page:https://git-for-windows.github.io/ Click "Download" on the page to enter the download list. You can choose the download version according to your preference. Choose to download the latest version here

Second, installation

After downloading, double-click to start the installation:

1. In addition to the ADVANCEDXXX option , the rest is fully selected

2. Select "Use Git Bash only"

3, select "Checkout as-is,commit as-is"

4, wait for the installation is complete.

2. Configure Git

Configure name and email

Command format:git config--global user.name "your name"

git config--global user.email "Your email address"

To improve the readability of the command output

Enter git config--global color.ui auto

When you enter ~/.gitconfig you will see the configuration

3. Set SSH KEY

Run the command to set SSH key:

ssh-keygen-t rsa-c "[email protected]"

Will output generating public/private RSA key pair.

Enter file in which to save the key

(/USERS/YOUR_USER_DIRECTORY/.SSH/ID_RSA):(press ENTER)

Enter passphrase (empty for no passphrase) (Enter password)

Enter same passphrase again (enter password again)

Your identification has been saved In/home/tekkub/.ssh/id_rsa.
Your public key has been saved in/home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
............ Finally, two files were obtained:~/.ssh/id_rsa and ~/.ssh/id_rsa.pub
4. Add SSH keysAdd the SSH key on GitHub, which adds the public key in "Id_rsa.pub". Open https://github.com/settings/ssh Add ssh key title random key is all the contents of ~/.ssh/id_rsa.pub at this time your GitHub registered primary mailbox will receive an email to remind you of the Following SSH key is added to your account: ....5. You can now authenticate and communicate with GitHub with your private keyinput Command ssh-t [email protected] output the authenticity of host ' github.com (x.x.x.x) ' Can ' T be established.< /c0>
RSA key fingerprint is ....
Is you sure want to continue connecting (yes/no)? Yes
warning:permanently added ' github.com,x.x.x.x′ (RSA) to the list of known hosts.
Hi xxx! You ' ve successfully authenticated, and GitHub does not provide shell access
Connection to github.com closed.6.git OperationCreate a local git folder to enter GIT init to initialize the operation clone repository to Local: git clone [email protected]:cheungchandevcoder/pythontools.git Edit and modify the code submit using git add file name to Add "staging Area" Use git log to view the commit log parameter --pretty=short only the first line of the commit log is displayed the git log-p filename shows the file changes after the commit --graph graphical display of the use git status View current status use git commit-m "record message" to submit the file in staging area and record the commit record, if you need to record the submission details, do not enter-M Will go into the Edit Submission editor General First line briefly summarize changes the second line of blank line the third row details the changes if you want to abort the submission , you can exit the editor and then abort the commit, and then commit to modify the submitted information with git. Commit--amend can be modified if the file is less you can use git commit-am "recored message" instead of add and commit-m two-step /c10> git diff View the difference between the current work tree and the staging area git diff HEAD to see the difference between the current work tree and the last commit git branch view current Branch -a displays information about the current branch. git checkout-b feature-a create feature-a branch and switch to Feature-a branch equivalent to git branch feature-a;git checkout Feature-a two commands git checkout master switch to Master branch git checkout- switch to previous branch merge branch git che Ckout master;git Merge--no-ff feature-a first switch to Master branch in merge this will open the editor after merging the merged information after merging the successful recovery history git reflog view the operations performed by the current warehouse will have various versions of the hash values restored to the historical state using the git reset--hard hash Resolve Conflicts modify conflicting files according to the conflict report again git commit-am "record message" to Compression History If you encounter problems such as spelling errors, you can add a commit and merge two history records into one using the git rebase-i HEAD-2 command opens the editor, pick 7a34294 add FE Ature-c pick 6fba227 Fix Typo The second pick can be changed to fixup Add remote repository git remote add origin [email protected]:cheungchandevcoder/pythontools.git This will set the remote repository to Origin .Push to remote repository push to master branch first switch to Master branch git push-u Origin master where-u means upstream (upstream) Set the Origin warehouse's m at the same time as push  The Aster branch is the upstream of the current branch of the local warehouse. push to a branch other than Master , instead of locally created feature-d branch switch to feature-d branch and then git push-u origin feature-d get feature-d branch of remote repository git checkout-b feature-d origin/feature-d push to remote feature-dgit push canUpdate the local feature-d to the latest state of the remote GIT pull Origin feature-d

Git Learning Summary

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.