git使用总结

1、设置用户名、邮箱

首先查看自己设置了没,设置了什么?

  • git config --list

      git使用总结

设置邮箱和用户名

  • git config --global user.name  "username"  
  • git config --global user.email  "email"  

修改已配置的信息

假如配置后,发现有信息配置错了,如何进行修改?

  • git config --replace-all user.name "name"
  • git config --replace-all user.email "[email protected]"

 

2、git模板设置

  • git config --global commit.template 路径

如果设置模板后提交代码了,没有设置 用户名,邮箱。怎么更改已经提交的信息呢?

    先设置邮箱,用户名后再输下面的命令

  • git config --amend --reset-author

3、查看分支、切换分支

  • 查看所有分支:git branch -a
  • 查看当前分支:git branch
  • 切换分支: git checkout 分支名 

git使用总结

4.查看当前做了修改的文件、如何提交代码? 

  • git satus 
  • git add 文件路径/文件名

       将单个修改文件加入暂存区

  • git add .

        将所有已修改文件加入暂存区

  • git commit 
  • git push

 以下是我工作中的一次代码提交过程

git使用总结

5.如何检出历史版本 

6.如何回退到历史版本

.......