记录一些常用的 Git 命令
常用
git clone git地址 本地路径
git add
git commit -m "message" 标记一下本次提交,利于回溯
git pull origin branchname 获取远程代码
git push origin branchname 将代码提交到远程
git status 查看没有被add进git版本库的文件
其他
git stash 如果错误的pull了代码,可以使用这个命令返回
分支
git branch
git branch -r
git branch -a
git checkout branchname
git branch -d branchname
git push origin --delete branchname
git merge branchname
git branch -m oldname newname
git checkout -b branchname
tag
git tag -a v0.0.1 -m "msg"
git tag
git show v0.0.1
git checkout -b newbranch tag
--
git push origin v0.0.1
git tag -d v0.0.1
git push origin :refs/tags/v0.0.1
回溯版本
git log
git reset —hard 版本号
git rebase
git rebase origin
git rebase --continue
git rebase - -abort
修改本地仓库git指向
步骤:
git
git remote add origin 新地址
git
把本地的项目上传到github
步骤:
git config --global user.name "github账户名"
-- .
git init
git add
git commit -m "message"
git remote add origin https://github.com:xxx/xxx.git
git push -u origin master