Git installation and command Detailed

I. Introduction download and install

Git is the world's most advanced distributed version control system

Author Linus Torvalds (Linus Torvalds)

About interested in the history of git can own Baidu, not described in detail here, the next line and directly open

Download: https://git-scm.com/downloads download the corresponding os version, and so can

Follow the prompts to select the default configuration next step can be completed.

 

Second, the local warehouse configuration and related operations

After installation is complete, the final step required is provided, at the command line as follows:

zhanh247@DESKTOP-5IG8MJC MINGW32 /e/git-home/home1
$ git config --global user.name "zhanh247"

zhanh247@DESKTOP-5IG8MJC MINGW32 /e/git-home/home1
$ git config --global user.email "[email protected]"

Git is a distributed version control system, you need to fill in as a user name and mailbox identification.

C: \ Users \ .gitconfig file in the path which you can see admin

--global represent global properties, all git projects will share property

 

About GIT development process, we can simply use the following figure depicts

 

 

 

Here's formal entry into git related operations and common commands

git init in the project folder to initialize the local repository
git status to view the current status of the file in the directory
git add <filename> to add files to the staging area


Write a comment git commit, committed to the local repository
git commit -m "footnotes" directly with comments submitted


git log <filename> to view the history of
git log --pretty = oneline <filename> Simple View


git reset --hard HEAD ^ submitted once fall back on
git reset --hard HEAD ~ n n rollback operations


git reflog <filename> to view the history of the version number of
git reset --hard version of history to fall back to the corresponding versions of
git checkout - <filename> Restore Files

 

Delete files from git, you need to delete the file, and then re-submit git add

 

Workspace (Working Directory): is your local PC hard disk directory

Local Library (Repository): workspace there is a hidden directory .git, it is the Git repository locally

Staging area (stage): generally stored in "git directory" of the index file (.git / index) in, so we put the staging area is sometimes called the index (index)

 

git branch <branch name> Create branch
git branch -v looking at branches


git checkout <branch name> handover branch
git checkout -b <branch name>


git checkout master to switch to the trunk
git merge <branch name> merging branches


Conflict: generally refers to the same code as the location of a file, when the two versions merged version of the management software can not determine which version should be retained in the end, so will prompt the file conflict, requires the programmer to manually determine the resolution of the conflict.

Conflict merge: merge conflicts occur when the program will be prompted CONFLICT keywords, command line extension will enter MERGING state, represents the state at this time is to resolve the conflict.

Resolve the conflict: the conflict can be found in the contents of the file and the conflict through git diff.

Then modify the contents of the file conflict, git again add <file> git commit and commit suffix MERGING disappeared, indicating complete conflict resolution.

 

Three, github hosting and upload

GitHub is a hosted Git project website, which offers versions of Git-based hosting service
URL: https: //github.com/

 

 

 

Increasing the remote address
git remote add <distal Code> <Remote Address>.
<Distal code> is remote link code, the code is generally used as a direct origin, it can also be customized.
<Remote Address> default remote link url
Example: git remote add origin https://github.com/user111/Helloworld.git


Pushed to the remote repository
git push <distal code> <local branch name>.
<Distal code> is a remote link code.
<Branch name> is the name of the branch mean it submitted, such as master.
Example: git push origin master


从GitHub上克隆一个项目
git clone <远端地址> <新项目目录名>。
<远端地址> 是指远程链接的地址。
<项目目录名> 是指为克隆的项目在本地新建的目录名称,可以不填,默认是GitHub的项目名。
命令执行完后,会自动为这个远端地址建一个名为origin的代号。
例 git clone https://github.com/user111/Helloworld.git hello_world


从GitHub更新项目
git pull <远端代号> <远端分支名>。
<远端代号> 是指远程链接的代号。
<远端分支名>是指远端的分支名称,如master。
例 git pull origin master

 

协作冲突:在上传或同步代码时,由于你和他人都改了同一文件的同一位置的代码,版本管理软件无法判断究竟以谁为准,就会报告冲突,需要程序员手工解决。

Guess you like

Origin www.cnblogs.com/zhanh247/p/12019962.html