Git commands and installation

 

https://blog.csdn.net/qq_40323256/article/details/92384334#%E4%B8%80%EF%BC%8Cgit%E4%B8%8B%E8%BD%BD%E5%8F%8A%E5%AE%89%E8%A3%85

Non-own

 

git: distributed version control software

Commonly used commands:

git add: the local file to the staging area

git commit: the submission of the staging area to the local repository (local branch, the default master branch)

git push: the local repository to push content to a remote repository (remote branch)

git pull: a remote repository (remote leg) content pulled to the local repository (the local branch)

git branch: View all the branches

git checkout xxx: xxx branch switching to

git checkout xxx -f: forced handover branches to xxx

git branch xxx: create a branch

git checkout -b xxx: xxx create and switch to branch

git branch -d xxx: xxx deleted branches

git branch -D xxx: xxx forced to remove branches

 

(Note: If you feel a bit difficult to write command, you can not use the write command of the desktop version of GitHub (highly recommended for beginners), refer to: https: //blog.csdn.net/zhangrunnanshuai/article/details/77841141)

A, download and install git
git official website to download: https: //git-scm.com/downloads, if that's official website download speed is slow, you can go here to download, very fast

 

 Installation is very simple, except where manually select "use git from xxx" Now, the other by default, all the way to next

 

Configuration path: configuration environment variable

 

Second, configure git: user and mailbox
on the desktop, right - [Git Bash Here]

 

input the command:

git config --global user.name "lijiang"
git config --global user.email "[email protected]"


Check whether the user name and mailbox configuration is successful, go to this path: C: \ Users \ Lijiang, find the file and open .gitconfig, if have the following content that success

 

Third, set up git server (remote repository): a unified hosting site (https://github.com/)
In order to avoid the key registration between the local and remote repository, you can configure ssh.

Configuring ssh: first in the local configuration, and then sent to the remote

To see if there .ssh file, enter the command: cd ~ / .ssh

No such file or directory appears that there is no .ssh file as follows:

 

If you do not .ssh file, we need to generate a local ssh file, just enter the command: "[email protected]" special attention ssh-keygen -t rsa -C capitalization and spaces, with a capital C! ! ! After three Enter to generate a local ssh

 

 

Sent to the remote:

Open: https: //github.com/settings/keys

 

 

Test connectivity to see whether the local repository and remote repository connection is successful, enter the command: ssh -T [email protected]

 

 

 

Fourth, the local New git project. git init
in the root directory of the file you want to send items folder, right [git bash here]

 

(Note: If the figure of '.git' folder does not appear, probably because .git suffix folder is hidden by default, so, there was no '.git' folder do not have to worry too much) 

Fifth, the establishment of the project in a remote git: https: //github.com/new


The following string is the unique identifier for remote projects, there are two ways, HTTPS, and ssh

 

 

Six local projects - projects associated with the remote
enter the command: git remote add origin [email protected]: LiJiangJiangJiang / myGitProjectRemote.git Note: The orange is a unique identifier of a remote project

 

 

Seven, the first release of the project (Local - Remote)
git add // file - the staging area, add back a "blank spot" says that all files in the current directory (Note: the middle point and add a space !!! Tai Hang) 

git commit -m "footnotes" // staging area - the local branch (default master)

git push -u origin master

 

GitHub now and then on the official website associated with the local project:

 

Eight, first download the project (remote - Local): git clone git @ XXX


Then find a store files in the project folder, and right in this folder inside [git bash here], enter the command: git clone XXX (Note: "XXX" is a unique identifier just copied) 

 

 Then you can see that the project is downloaded to just the new local folder "myGitProjectRemote" a. At this time, management will find a version of the directory ".git" also came

 

Nine, to submit project (Local - Remote), three steps
in the current working directory, right [git bash here]

git add .

git commit -m "Submissions"

git push origin master (note: this is a non first submission, so there is no "-u")

 

 

Ten, update the project (remote - local), the command: git pull

 


(Note: If the git pull command being given, you can try this command: git pull origin master)

 

 
----------------
Disclaimer: This article is CSDN bloggers "- Li Jiang 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/qq_40323256/java/article/details/92384334

Guess you like

Origin www.cnblogs.com/fl-1998/p/12668857.html