git常用命令

一、上传代码

git -A

git commit -a -m 'fixbug'

git push

——————————————————————

二、恢复上一个版本

git reset --hard

git pull

————————————————————————

三、下载代码

git clone

git branch 切换到主分支,成功后,会提示 Switched to a new branch 'test'

git branch -a 列出所有分支

git checkout  -b keshihua 拉新分支

git checkout keshihua 切换新分支

——————————————————————

四、解决冲突

git stash pop 可用来暂存当前正在进行的工作

git pull

git status命令可以列出当前目录所有还没有被git管理的文件和被git管理且被修改但还未提交(git commit)的文件.。

——————————————————————

五、删除本地分支

git branch -d xxx

——————————————————————

六、VI

退出按 esc :q!

:w   保存文件但不退出vi

:w file 将修改另外保存到file中,不退出vi

:w!   强制保存,不退出vi

:wq  保存文件并退出vi

:wq! 强制保存文件,并退出vi

q:  不保存文件,退出vi

:q! 不保存文件,强制退出vi

:e! 放弃所有修改,从上次保存文件开始再编辑

——————————————————————

git 报错:

1.git commit -a -m ‘’ 报错如下:

 

Your name and email address were configured automatically based

on your username and hostname. Please check that they are accurate.

You can suppress this message by setting them explicitly. Run the

following command and follow the instructions in your editor to edit

your configuration file:

 

解决:

git config --global user.email  "you@example.com"

git config --global user.name  "Your Name"

2.The following untracked working tree files would be overwritten by merge

 

解决:git clean -d -fx “”

posted on 2017-02-15 14:34  积累学习  阅读(105)  评论(0编辑  收藏  举报

导航