You are not allowed to add pages
Direct Link
Direct Link
收集常用Git命令。
git clone git://192.168.0.1/xinsi/repo.git git clone -b dev http://192.168.0.1/xinsi/repo.git
git add -u git commit -m "Some message" git push
git pull
git branch git branch -a git branch -v git branch -r
git checkout -b dev git branch --set-upstream-to origin/远程分支名 本地分支名
git branch --set-upstream-to=origin/<branch> you_branch git branch --set-upstream-to origin/远程分支名 本地分支名
git branch -m old_branch new_branch
git checkout dev
git push --set-upstream origin dev
git branch -d <BranchName>
git push origin --delete dev
git checkout master git merge dev
git checkout -b 本地分支名 origin/远程分支名
git checkout -b dev # Create local branch "dev" git push origin dev # Push branch "dev" to remote
git branch -a # List all branchs on local and remote git checkout dev # Checkout branch "dev"
git checkout .
git stash
git stash pop
git reset --hard HASH
git reset --soft HASH
git fetch --all git reset --hard origin/master 其中最后的master可以修改为其他branch
git commit -m 'initial commit' git add forgotten_file git commit --amend
// files git reset HEAD <filename> // all git reset --hard git pull
git log
清除密码
git config --system --unset credential.helper or git config --global credential.helper reset
保存用户名和密码
git config --global credential.helper store
设置默认用户名称和邮箱
git config --global user.name "your name" git config --global user.email "hour mail box"
git archive -o ../xxx.zip HEAD
git config --global core.quotepath false
在 git log 时中文依然不能显示,首先试试用
git --no-pager log
能不能显示中文,如果可以,则设置pager为more:
git config --global core.pager more
以及,其他的一些解决办法: 进入你的项目根目录
1.设置git gui的界面编码
git config --global gui.encoding utf-8
2.设置 commit log 提交时使用 utf-8 编码,可避免服务器上乱码,同时与linux上的提交保持一致!
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8
注:
windows系统默认编码为gbk,可改成gbk
如果系统设置了:
export LANG=zh_CN.UTF-8
则日志输出编码设置为utf-8
git config --global i18n.logoutputencoding utf-8
3.在 /etc/profile 中添加:
export LESSCHARSET=utf-8
在试一下问题解决了!
git fetch --all git reset --hard origin/master # 如果在主分支上 or git reset --hard origin/<branch_name> # 如果在非主分支上 说明: git fetch从远程下载最新的,而不尝试合并或rebase任何东西。 然后git reset将主分支重置为您刚刚获取的内容。 --hard选项更改工作树中的所有文件以匹配origin/master中的文件。
列出标签 git tag 新建标签 git tag 标签名 -m "信息"
git branch -b dev # Create local branch "dev" git push origin dev # Push branch "dev" to remote
git checkout dev
commit后未push,修改信息命令: git commit --amend
ssh-keygen -t rsa -C "youremail@example.com"
针对警告: warning: LF will be replaced by CRLF in xxxxxxxx. The file will have its original line endings in your working directory. git config core.autocrlf false (仅对当前git仓库有效) git config --global core.autocrlf false (全局有效)
备份当前的工作区的内容 git stash save "comment" 查看临时列表 git stash list 查看修改 git stash show stash{0} 清除所有缓存的stash git stash clear
提交时转换为LF,检出时转换为CRLF git config --global core.autocrlf true 提交时转换为LF,检出时不转换 git config --global core.autocrlf input 提交检出均不转换 git config --global core.autocrlf false
git stash git stash list git stash pop = git stash apply + git stash drop
记录所有子模块的文件
[submodule "app/pm2"] path = app/pm2 url = git@codeup.aliyun.com:xs/webapp/app.pm2.git
[submodule “apps/pm2”]
url = git@codeup.aliyun.com:xs/webapp/app.pm2.git active = true * .git/modules/<color #ed1c24>app/pm2</color> 子模块仓库的副本,存放子模块仓库本身的.git目录文件
指向主仓库记录子模块的路径
gitdir: ../../.git/modules/<color #ed1c24>app/pm2</color>
git submodule
注:
git sumodule add <remote-URL> [name] git add name git commit -m "add submodule" git push origin master
git checkout v2.0 cd sub-module git init git add sub.txt git commit -m "version 1.0 of sub-module" git remote add origin https://github.com/bitmingw/sub-module.git git push -u origin master
cd .. # main-module/ git rm -r sub-module git commit -m "remove sub-module directory"
main-module/ git submodule add https://github.com/bitmingw/sub-module.git git commit -m "add submodule version 1.0"
git submodule deinit <Submodule>
git rm --cached <Submodule>
git commit -am "Remove a submodule."
git submodule init git submodule update
或
git submodule update --init --recursive