Detailed explanation of git use

Git is a very important tool for Linux source code management, and it is also very practical. It is very necessary to learn to use git in daily work.

1. Common git commands
1) Initialize git
git init
2) Add personal information before use
git config --global user.name "your name"
git config --global user.email "your email"
3) View the current modification status
git status
4) Add a new file
git add filename
git add *
5) Commit record
git commit -m "your comment" /* For the case of adding a new file with git-add */
git commit -a -m "your comment" / *
Use */ for the case of no new files
added
Change any other file modification content and git status information)
git reset --soft is equivalent to git reset --soft HEAD (see later description)
8) Default recovery (restore git index and git status status, without changing the content of any modified files)
git reset --mixed is equivalent to git reset is equivalent to git reset HEAD is equivalent to git reset --mixed HEAD
9) HEAD, HEAD^, HEAD^^, HEAD^<n> respectively represent the current commit, the penultimate commit, the penultimate third commit, and the penultimate nth commit
git reset --hard HEAD^
git reset -- soft HEAD
10) View a modification
git show HEAD is equivalent to git show
git show HEAD^
git show HEAD^^
git show HEAD^<n>
10) View all modification records
git log
11) Clone git
git clone src_git target_git
12) Pull Branch
git branch new_branch
13) View branch
git branch
has a branch master by default
14) Switch branch
git checkout branch_name
git checkout -b new_branch After creating new_branch, switch to new_branch
15) Delete branch
git branch -d delete_branch
16) Merge branch
git merge src_branch
17) Synchronize clone's git repository
git fetch origin
git merge origin/master
18) Remote git access
git pull remote_git [local_git]
19) Update remote git
git push remote_git current_branch

 

Reprinted from: http://blog.chinaunix.net/uid-7295895-id-2971859.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944237&siteId=291194637