git commit --amend -m ""
谬误提醒
error: failed to push some refs to 'https://github.com/xxx/xxx.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
**这是因为近程仓库曾经批改了,所以要先fetch,后pull
最初能力push**
提交近程仓库出错
src refspec master does not match any
提交近程仓库出错,没有add,commit
git根本命令
Git global cofig
git config --global user.name "John Doe
git config --global user.email johndoe@example.com
Git init
Git add/commit -m
Git log:历史记录,最近到最远
Git reset –-hard HEAD^ or HEAD~100//回退100
Git reset –hard sha号
有HEAD指针指向头
Git reflog:记录每次命令
Work tree stagereposity
Git diff HEAD – 文件名 //查看work tree与repo
git diff HEAD -- readme.txt工作区和版本库外面最新版本的区别
Git checkout discard work tree的change Git checkout – 文件名
Git reset既能够版本回退,也能够把暂存区的扭转撤销掉(unstage)
在work tree删除文件,Git rm:从库中删除文件 ,之后要commit,才能够从库中删除
Git checkout – 文件名复原从repository
git log --graph命令能够看到分支合并图。
Git remote add origin(名字)
git remote add origin https://github.com/xxx/learngit.git
git push -u origin master //第一次
git push origin master
git clone近程库
master指向最新的提交,再用HEAD指向master
git checkout -b feature1 //建设分支并转换到分支
Git branch 建设分支
Git checkout 分支名字,转到分支
git branch命令会列出所有分支,以后分支后面会标一个*号
git merge dev合并到dev分支 --no-ff参数,示意禁用Fast forward
git branch -d dev 删除分支
git log --graph命令能够看到分支合并图。
Git stash list
git stash pop,回到工作现场,discard stash
git remote –v //近程信息
git push origin <branch-name>推送本人的批改;
如果推送失败,则因为近程分支比你的本地更新,须要先用git pull试图合并;
如果git pull提醒no tracking information,则阐明本地分支和近程分支的链接关系没有创立,用命令git branch --set-upstream-to <branch-name> origin/<branch-name>。
git tag <tagname>用于新建一个标签
git show <tagname>查看标签信息:
git tag -a <tagname> -m "blablabla..."能够指定标签信息;
git tag能够查看所有标签。
git tag -d <tagname>能够删除一个本地标签;
• 命令git push origin <tagname>能够推送一个本地标签;
• 命令git push origin --tags能够推送全副未推送过的本地标签;
git push origin :refs/tags/<tagname>能够删除一个近程标签。
Git show HEAD
Git config –list –show-origin
Git diff work tree和stage的差异
Git diff –staged
.gitignore能够疏忽不必要的文件
Blame:last modification on each line of file
Git push –u 出错,control panel/user/credential manager
git 删除commit
git rebase -i HEAD~
程序是反向的
git clone某分支
git branch -a
git checkout -b bugfix-2.0x origin/bugfix-2.0.x
git pull origins
//
git remote show origin
git checkout --track origin/serverfix //本地 serverfix追踪近程的 serverfix
git本地/近程分支名批改
git branch -r //列出近程分支
git branch -a//列出所有,蕴含近程与本地
git branch -v//verbose
git branch -m old_name new_name
git push origin --delete origin/old_name //删除近程分支
git push origin serverfix //本地 serverfix追踪近程的 serverfix
git pull -u origin new_name:newname new_name追踪近程newname
git remote prune origin //近程曾经删除了,然而本人fetch的近程还在,应用prune
git 近程
git remote -v //verbose
git remote add pb https://github.com/paulboone/ticgit //增加近程
git remote show origin //查看近程
git remote remove origin//移除
git remote rename pb paul//重名
git log
git log -p -2 //最初两个commit
git log --stat
git log --pretty=oneline
git log --pretty=format:"%h -- %an--%ar--%s"
git log since=2019.01.01 //自从2019.01.01到当初
git log until=2019.01.01
git log --since=2.weeks/2.months/2.years
git log -S function_name
发表回复