按照CRUD的原则整理一下git基本命令

来源:互联网 发布:mongodb 连接数据库 编辑:程序博客网 时间:2024/06/05 17:11
按照CRUD的原则整理一下git基本命令

==============Create Like===============

create project

git init


add changes to the staging area
git add <file>

add remote repository
git remote add origin <repo>

create branch 
git branch <new_branch_name> <base_branch>

==============Read Like===============
get project status
git status
 
compare changes
git diff <file>

view the history of changes
git log <file>

binary search of the repository looking for which commit introduced the problem
git bisect start
git bisect bad
git bisect good HEAD~5


know who worked on certain sections 
git blame <file>

view the changes made in the commit 
git show

switch to the new branch
git checkout <new_branch_name>

check the current branch
git branch

==============Update Like===============
commit changes to the repository
git commit -m "commit msg"

push changes to remote repository
git push

push changes on specific branch to remote repository
git push origin <branch_name>

sync changes from remote repository
git pull

download changes from remote repository - will not apply
git fetch

apply the changes from remote repository
git merge <repo>

apply the changes from local branch
git merge <merge_from_branch>

unwind and replay the changes in the branch
git rebase

merge specific files
git cherry-pick <new_branch~1>

==============Delete Like===============
give up or undo changes
git checkout <file>

give up or undo changes in staging area
git reset HEAD <file>

give up all changes
git reset --hard 

give up the changes committed
git revert <commit-ish>

delete branch
git branch -d <branch_name>
0 0