1.git 常用命令 $ git remote add origin git@github.com:yeszao/dofiler.git # 配置远程git版本库 $ git pull origin master # 下载代码及快速合并 $ git push or……
1.git 常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| $ git remote add origin [email protected]:yeszao/dofiler.git
$ git pull origin master $ git push origin master $ git fetch origin $ git branch $ git checkout master $ git checkout -b dev $ git commit -m "first version" $ git status $ git log $ git config --global core.editor vim $ git config core.ignorecase false $ git config --global user.name "YOUR NAME" $ git config --global user.email "YOUR EMAIL ADDRESS" `2. 别名 alias```bash $ git config --global alias.br="branch"
$ git config --global alias.co="checkout"
$ git config --global alias.cb="checkout -b"
$ git config --global alias.cm="commit -m"
$ git config --global alias.st="status"
$ git config --global alias.pullm="pull origin master"
$ git config --global alias.pushm="push origin master"
$ git config --global alias.log="git log --oneline --graph --decorate --color=always"
$ git config --global alias.logg="git log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative"
`3. 创建版本库```bash $ git clone <url>
$ git init
`4. 修改和提交```bash $ git status $ git diff
$ git add .
$ git add <file>
$ git mv <old> <new>
$ git rm <file>
$ git rm --cached <file>
$ git commit -m “commit message”
$ git commit --amend
`5. 查看历史```bash $ git log
$ git log -p <file>
$ git blame <file>
`6. 撤销```bash $ git reset --hard HEAD
$ git reset --hard <version>
$ git checkout HEAD <file>
$ git checkout -- <file>
$ git revert <commit>
`7. 分支与标签```bash $ git branch
$ git checkout <branch/tag>
$ git branch <new-branch>
$ git branch -d <branch>
$ git tag
$ git tag <tagname>
$ git tag -a "v1.0" -m "一些说明"
$ git tag -d <tagname>
$ git checkout dev
$ git cherry-pick 62ecb3 `8. 合并与衍合```bash $ git merge <branch>
$ git merge --abort
$ git merge dev -Xtheirs
$ git rebase <branch>
`9. 远程操作```bash $ git remote -v
$ git remote show <remote>
$ git remote add <remote><url>
$ git remote remove <remote>
$ git fetch <remote>
$ git pull <remote><branch>
$ git push <remote><branch>
$ git push <remote>:<branch/tag-name>
$ git push --tags
`10. 打包```bash $ git archive --format=zip --output ../file.zip master
$ git archive --format=zip --output ../v1.2.zip v1.2
$ git archive --format=zip v1.2>../v1.2.zip
`11. 全局和局部配置```bash 全局配置保存在:$Home/.gitconfig 本地仓库配置保存在:.git/config `12. 打包```bash
$ git commit -m "add local source"
$ git pull origin master
$ git merge master
$ git push -u origin master
|
本文标题: git常用命令大全
发布时间: 2024年01月20日 00:00
最后更新: 2025年12月30日 08:54
原始链接: https://haoxiang.eu.org/bcc661d/
版权声明: 本文著作权归作者所有,均采用CC BY-NC-SA 4.0许可协议,转载请注明出处!