> 文章列表 > git 一些常用命令 后期继续补充~

git 一些常用命令 后期继续补充~

git 一些常用命令 后期继续补充~

HEAD      当前版本的指针,当切换本地版本的时候会快速指向指定版本文件

master  git为我们创建主分支

origin  远程仓库的名称

 

  1. git init 初始化一个新的 Git 仓库。

  2. git clone [repository] 从远程仓库克隆代码到本地。

  3. git add [file/path] 将改动添加到暂存区。

  4. git commit -m "[message]" 将已经添加到暂存区的更改提交到本地仓库并添加一条描述信息。

  5. git status 查看当前工作区和暂存区的状态。

  6. git log 查看提交历史。

  7. git diff [file] 查看文件在工作区和暂存区的差异。

  8. git branch 查看当前所有分支。

  9. git checkout [branch-name] 切换到指定分支。

  10. git merge [branch-name] 合并指定分支到当前分支。

  11. git pull 从远程仓库拉取最新代码。

  12. git push 将本地代码推送到远程仓库。

  13. git remote add [remote-name] [remote-url] 添加远程仓库地址。

  14. git remote -v 查看当前所有远程仓库地址。

  15. git reset [commit-hash] 撤销指定的提交。

  16. git revert [commit-hash] 撤销指定的提交并创建一个新的提交来记录这个撤销操作。

  17. git fetch origin 远程分支名 直接切换本地没有的远端分支

  18. git config user.name  查看用户名

  19.  git config user.password   查看密码

  20. git config user.email   查看邮箱

  21. git config --list       查看配置信息

  22. git config --global user.name “xxxx(新的用户名)”    修改用户名

  23. git config --global user.email “xxxx@xxx.com(新的邮箱)” 修改邮箱

  24. git config --global user.password “xxxx(新的密码)”  修改密码