Git常用命令汇集
开发中常用到的Git命令大集合
一张图大致了解最基础的Git命令流程
图中名词解释
Workspace: 工作区Stage: 暂存区Local: 本地仓库Remote: 远程仓库
最基础的命令
git init
git clone user@server:path/repo.git
git clone https://server/path/simpale
git add simple-file
git add
[file
]
git add -A
git add --all
git pull
[remote
] [branch
] [--rebase
]
git commit -m
[msg
]
git push
[remote
] [branch
] [--force
]
git fetch
[remote
]
git merge
[branch
]
git rebase
[branch
]
git rebase --continue
git checkout -b featrues/sample1 origin/featrues/sample2
其他基础命令
git remote add
[origin
] [url
]
git remote
[-v
]
git status
git log
git diff
git reset --soft HEAD~1
git revert
[commit
]
git branch
git branch -r
git branch -a
git branch -d
[branch-name
]
git branch
[branch-name
]
git checkout
[branch-name
]
$
git push origin --delete
[branch
]
$
git branch -dr
[remote/branch
]
git checout master
git pull
git checkout -b featrues/sample
git push origin featrues/sample
常用的进阶命令
工作中经常遇到需要临时改其他分支代码的场景,而此时本分支的改动尚不能提交,此时stash命令就派上了大用场。
git stash
git pop
git stash list
git stash save
[msg
]
git stash apply stash@
{n
}
git stash pop stash@
{n
}
git stash drop stash@
{n
}