echo "# roscpp" >> README.md
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/xuehu96/xxxx.git
git push -u origin master
git remote add origin git@gitee.com:xuehu96/tcp_hello_client.c.git
git push -u origin master
git pull --allow-unrelated-histories
git remote add mirror git@github.com:xuehu96/qt_exercise.git
git pull origin master
git pull mirror master
git push origin master
git push mirror master
git remote set-url origin git@gitee.com:xuehu96/note.git
git remote set-url --add origin git@gitee.com:xuehu96/note.git
git remote set-url --add origin git@github.com:xuehu96/qt_exercise.git
提交git push -u origin dev2
提交不同名称
拉取git checkout -b dev2 origin/dev2
删除git push origin --delete develop
git checkout master
git pull (git pull origin master)看看远程有没有修改 有就先拉回来
git merge dev2
git push origin master 推到远端库
git reset HEAD test.txt 讲删除的文件从暂存区恢复到工作区
git checkout -- test.txt 将工作区中的修改丢弃掉
git config --global user.name 'xuehu96'
git config --global user.email 'xuehu96@vip.qq.com'
git commit -m '提交消息'
git commit --amend -m '修正消息'
-p 展开每次提交内容差异
-n 金查看n次更新 -3
--graph
查看操作日志
git reflog
查看远程分支的log
git log origin/master
git log refs/remote/origin/master
*.a #忽略所有.a文件
!lib.a #lib.a除外
build/ #忽略build/目录下所有文件
删除已经追踪的代码 重新追踪
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
git branch 分支名 创建分支
git checkout -b 分支名 创建分支 并且切换到新分支
git checkout newbranch 切换分支
git branch -d newbranch 删除分支
分支改名
git branch -m master master2
git merge newbranch 把newbranch分支的修改合并到当前分支上
禁用fast-forward
git merge --no-ff dev
git reset --hard HEAD^
git reset --hard HEAD~1
git reset --hard commit_id
git check -- test.txt 修改工作区 丢弃掉相对暂存区的内容
git reset HEAD test.txt 暂存区的内容移除到工作区
git diff 比较暂存区和工作区
git diff HEAD 比较最新提交和工作区
git diff -cached 比较尊新提交和暂存区的区别
git add
git commit
git rm
git stash
git stash list
git stash apply (stash内容不删除 git stash drop stash@{0}手动删除)
git stath pop
push 推送
pull 拉取并且合并
pull == fetch + merge
git remote add origin http://
origin 代表远程仓库
git push -u origin master 做一次关联
git remote show 显示所有关联的远程仓库
git remote show origin 列出远程仓库的详细信息
git remote set-url origin git@gitee.com:xuehu96/note.git
git remote add origin git@github.com:xuehu96/note.git
git remote show origin
yes 发现不行
ssh-keygen 回车X3
cd
cd .ssh
到github上 setting Deploy keys 上传公钥 √ Allow write access
git remote show origin 可以看到Fetch URL 和 Push URL
git push -u origin master//做一次关联
pull = git fetch + git merge
git fetch
git branch -av
git merge origin/master
git checkout -b develop
git push --set-upstream origin 分支名
git push --set-upstream origin develop[:develop2]
[分支不同名的时候会出错git push]
[git push origin HEAD:develop2推送本地分支到远程不同名分支]
git push -u origin test
git pull
git checkout -b test origin/test
git checkout --track origin/test
git push的完整写法
git push origin src:dest
git push origin :develop删除develop
git push origin --delete develop
重命名远程分支
删掉远程分支 本地改名 推送
git remote show origin
git remote prune origin
git tag v1.0.1
创建一个带注释的标签
git tag -a v1.0.2 -m 'release version'
git tag -d tag_name
git tag -l '?2*' V2.X
打标签git tag -a V3.0 -m 'V3.0'
git push origin V3.0
git push origin --tags//一次推送所有标签
git pull
删除远程标签
git push origin :ref/tags/V6.0
git log --author="xuehu96" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
分支
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.cm commit
git config --global alias.br branch