# 列出远程仓库的简写(shortname)
# 如果进行了clone, 至少能看到origin,这是Git给你克隆的仓库指定的默认名字
git remote
# 列出远程仓库的简写(shortname)与其对应的URL
git remote -v
# 列出远程origin的详细信息
git remote show origin
# 添加远程仓库,指定一个简写名字,可以用这个简写来代替URL
git remote add <shortname> <url>
# 对上次提交(last commit)做修改
# You’ll often want to do two basic things to your last commit:
# simply change the commit message
# or change the actual content of the commit by adding, removing and modifying files.
# 仅修改提交信息,直接敲命令就行
git commit --amend -m "xxx"
# 修改上次提交的文件内容
1.对文件进行修改,然后git add
2.git commit --amend会用新的commit替换上一次commit
# push了一个commit,想撤销
git log # 1.找到想要退回到的commit_id
git reset --hard <commit_id># 2.本地回到上一个commit_id(也可以使用--soft,仅移动HEAD指向)
git push origin branchName --force# 3.推送到服务器,一定要加 --force参数
git push
git push <远程仓库shortname> <本地branch>:<远程分支名>
# 将本地serverfix分支推送到远程仓库上的awesomebranch分支
git push origin serverfix:awesomebranch
# 省略远程分支,表示将本地分支master推送到与之存在追踪关系的远程分支(通常两者同名),如果该远程分支不存在,则会被新建
git push origin master
# 省略本地分支,表示删除指定的远程分支.等同于推送一个空的本地分支到远程分支
# 等同于git push origin --delete master
git push origin :refs/for/master
# 如果当前分支与远程分支存在追踪关系,则本地分支和远程分支都可以省略,将当前分支推送到远程origin仓库的对应分支
git push origin
# 如果当前分支与多个远程仓库存在追踪关系,可以使用-u参数指定一个默认的远程仓库
# 这样后面就可以直接使用git push(会推送到默认的远程仓库)
git push -u origin master
发生的变化:
git pull
git pull <远程仓库> <远程branch>:<本地branch>
# 取回远程仓库某个分支的更新,再与本地的指定分支合并
# 如果远程分支是与当前分支合并,则可以省略 本地branch
Git push 常见用法
杰哥课堂 git
git clone,push,pull,fetch
git - 简明指南
Git修改已提交commit的信息