git—— Learning mind map


Environmental Science

Centos 6.5 X64

Reference resources :

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

install

   yum install git

Installed version :1.7.1



Make sure along the way



Input git command , Verify that the installation was successful


 

Create repository

1. Specify the file location , Create warehouse Directory ; for example :



2. Use git init establish git Manageable Libraries


 

Command Introduction

add to 、 Upload files

Use command :git add ,git commit



summary :

Add files to Git Warehouse , A two-step :

·         First step , Use command git add <file>, Be careful , Can be used repeatedly , Add multiple files ;

·         The second step , Use command git commit, complete .

 

View status and diff

Use command :git status,git diff

modify readme.txt, preservation

perform git status



It can be found that the document just now is not marked as modified , But they didn't submit it

see file diff, Use command git diff <file>



Look at the file records

git log

 

Backtracking version

git reset

stay git in , use HEAD Represents the current version , That is, the latest submission 3628164...882e1e0( Pay attention to my submission ID It must be different from yours ), The last version was HEAD^, The last version is HEAD^^, Of course up 100 Version (s) 100 individual ^ It's easier not to count , So it's written as HEAD~100.

Back to the previous version


 

according to commit id to flash back

see git Operation command

git reflog


Undo modify

Back to the last time git commit perhaps git add state

git checkout -- <file>  The file has been modified and saved without add

git reset HEAD <file> The file has been modified and saved add, But no commit

according to git status Prompt for the corresponding fallback operation

Delete file

git rm <file>


 

Recovery of deleted files by mistake ( File deletion not submitted git)

git checkout -- <file>


Remote associated version Library

Associate a remote library , Use command

git remote add [<options>] <name><url>

git remote add originRepogit@server-name:path/repo-name.git;

Use command git push -u origin master First push master All content of branch ;

thereafter , After each local submission , As long as necessary , You can use the command git push origin master Push latest changes ;

Pull the remote version Library ( Clone remote Libraries )

git clone

Branch

Create a branch :git checkout -b ban

View branches :git branch

Switch branches :git checkout <branch>

Merging branches :git merge <branch> Merge the specified branch to the current branch ,

Use git log --graph --pretty=oneline --abbrev-commit View branch merge graph

Delete the branch :git branch –d <branch>



* Identify the branch currently in use

Pull and push data to remote

·         View remote library information , Use git remote -v;

·         If a new local branch is not pushed to the remote , It's invisible to others ;

·         Push branch from local , Use git push origin branch-name, If push fails , First use git pull Grab remote new submission ;

·         Create local branches corresponding to remote branches , Use git checkout -b branch-name origin/branch-name, The names of the local and remote branches are best the same ;

·         Associate the local branch with the remote branch , Use git branch --set-upstream branch-name origin/branch-name;

·         Grab branch from remote , Use git pull, If there is a conflict , Deal with the conflict first .

 

label

tagging :git tag < tagName > <commit id/HEAD>

View tab :git show <tagName>

Remove the label :git tag –d <tagName>

Push tags to remote :git push <repository> <tagName>

Remove remote label :git push <repository>:refs/tags/<tagName>