美文网首页
git的基本使用

git的基本使用

作者: 华_5b04 | 来源:发表于2018-08-07 16:00 被阅读0次

    初始化:git init

    增加本地代码与仓库的链接:git remote add origin 地址

    增加本地代码:git add .

    查看提交的状态:git  status

    增加提交的信息: git commit -m "提交"

    上传本地代码到仓库中:git push origin master

    暂存自己修改的内容:git stash

    更新代码:git pull 

    更新暂存代码到本地:git stash pop stash@{0} 

    git stash list 查看暂存的代码

    远程代码覆盖本地:git fetch --all,  git reset --hard origin/master

    查看历史提交的代码的版本:git log ,git log --pretty=oneline 文件名

    查看某一次的提交代码:git  show 版本号 

    在做代码审查,或者要快速浏览其他协作者提交的更新都作了哪些改动时,就可以用这个选项。此外,还有许多摘要选项可以用,比如 --stat,仅显示简要的增改行数统计:git log --stat    每个提交都列出了修改过的文件,以及其中添加和移除的行数,并在最后列出所有增减行数小计。还有个常用的 --pretty 选项,可以指定使用完全不同于默认格式的方式展示提交历史。

    git pull origin master  --allow-unrelated-histories

    删除:git  remote rm  ***;

    创建分支 :git branch -c  <分支名>  

    删除本地分支:git branch -d  <分支名>  

    删除远程分支分支:git branch -r -d origin/<分支名>  

    创建tag:git tag -a v1.0.1 -m “企业审核”;

    创建tag后提交:git push不会自动提交到远程分支上,用以下命令:git push origin v1.0.1

    仓库更换步骤:

    1.增加另一个仓库的地址:git remote add 名称(自定义) 地址,

    2.解决readMe的冲突

    3.git pull github(自定义的新的仓库的名称) master --allow-unrelated-histories

    4.提交代码到新的分支上,包含了所有的信息:git  push github  master

    附件:

       github的一些开源项目地址:

            quartz:https://github.com/quartz-scheduler/quartz.git

            mybatis:https://github.com/mybatis/spring.git

            tomcate:  https://github.com/apache/tomcat.git

            redis:  https://github.com/antirez/redis.git

            spring-boot :https://github.com/spring-projects/spring-boot.git

            spring:    https://github.com/spring-projects/spring-framework.git

            durid: https://github.com/alibaba/druid.git

    相关文章

      网友评论

          本文标题:git的基本使用

          本文链接:https://www.haomeiwen.com/subject/zzlavftx.html