zoukankan      html  css  js  c++  java
  • git 提代码时的相关命令,Mark一下

    以前用命令提代码都是复制粘贴,现在换了工作后,特别是回退代码的命令又忘了,去网上查了好久,心累。特此Mark一下
    
    1. 打patch:
      1.1 git diff >> ljh.patch
      1.2 patch –p1 < ljh.patch
    2. 查看本地修改与服务器上的区别,一般都是用beyond compare,其实可以用meld +文件的绝对路径:
      eg:meld /home/longjunhao/src/android-trident-trinity/packages/inputmethods/IMESmartisan/app/src/main/java/com/smartisanos/ime/keyboard/view/IMETextView.java
    3. 隐藏修改,常用命令:
      1.1 git stash
      1.2 git stash pop
      1.3 git stash list
      1.4 git stash save tmp
      1.5 git stash apply stash@{0}
      最后这两个命令也类似,不习惯用
    4. 查找修改历史:
      git blame –L 92,99 xxx.java
    5. 查找某个变量:
      进入要查找的路径下执行:grep -rw “xxx” ./或者grep -rw 'xxx' ./
      如果不是全词查找可以为:grep -r "xxx" ./
      如果需要把查找的内容导出到文件,可以执行:grep -r "xxx" ./ > ~/longjunhao.log &
    6. 查找某个文件的提交记录:gitk 文件   eg: gitk app/src/main/java/com/smartisanos/ime/view/popwin/SoftComposingText.java 7. 提代码流程:   1.1 git pull   1.2 git status   1.3 git add   1.4 git status   1.5 git commit –m “提交备注”   1.6 二次提交:git commit –amend   1.7 二次提交只修改commit时:git commit --amend –s   1.8 git push 或者 repo upload .eg: git push EMUI HEAD:refs/for/master 或者git push -u origin master 8. 更新代码常用命令:   1.1 repo sync -c packages/app/Mms【根路径下跟新某个模块代码】、   1.2 git pull 在模块路径下更新拉代码所在的主线代码   1.3 git pull smartisanos trinity_dev   1.4 git pull --rebase smartisanos trinity_dev  【注】代码合入之后,再git pull跟新代码时,【如果没有新建分支,直接在主线上提交代码,pull的时候最好加下--rebase,这样当代码merged之后,更新代码再git status会显示本地代码和主线代码一致。eg:用git pull --rebase smartisanos trinity_dev而不是用git pull smartisanos trinity_dev 其中smartisanos trinity_dev是分支名】 9. 撤销代码:   1.1 git reset --soft HEAD^ 撤销已经提上但没有合入的代码   1.2 git reset 撤销已经add的但是没有提上的代码   1.3 git reset --hard HEAD^是什么意思呢? 10. 编译代码:   1.1 在Android.mk路径下:mm 或者mma   1.2 make Mms -j12(需要在Android工程的根路径下,执行make之前,先要执行:source build/envsetup.sh 和 lunch选项目)
    11. ubuntu系统下安装软件:   1.1 安装deb软件:sudo apt-get -f install   1.2 解压zip:unzip FileName.zip 12. 安装apk:   1.1 adb install -r   1.2 adb push ,如果用push需要重启,最近刚发现不重启也行,直接杀死进程即可:eg命令1:adb shell am force-stop com.smartisanos.ime或者用命令2:adb shell pkill ime是杀死所有包含ime的进程 13. 分支相关命令:   1.1 新建分支:repo start ljh .   1.2 切换分支:git checkout ljh   1.3 强制切换其他主线分支:eg: git co smartisanos/trident-trinity -b trident-trinity   1.4 git fetch会把远程服务器上所有的更新都拉取下来   1.5 git branch –vv   1.6 git branch –a   1.7 其中git co smartisanos/trident-trinity -b trident-trinity :是基于远程的smartisanos/trident-trinity分支新建一个trident-trinity分支。即: git checkout 服务器分支 -b 本地分支 14. 查找crash堆栈的发生时间:   date -d @时间(去掉后三位)eg:date -d @1523673060 15. adb logcat -s TAG 用命令查看log   参考: https://blog.csdn.net/listening_music/article/details/7518990 16. 用命令截取手机屏幕:adb shell screencap -p /sdcard/1.png 17. 在Androidstudio annotate上看不到历史提交记录,在工程路径下执行git fetch --depth 100000 就行了 18. 服务器的分支更新:git fetch --all 或者 git fetch 19. 查看命令的记录 :history 20. 查找命令执行的历史记录:history。如果想直接执行历史记录中的某一个命令:ctr+r,然后输入模糊匹配,确定后回车即可 21. github 提代码命令   1.1 git commit -m "add AIDL demo"   1.2 git push -u origin master
    22. 如果多人多个路径同时提交代码时,尽可能的多执行rebase操作,如下命令:   1.1 git pull --rebase origin t11   1.2 git status ./   1.3 git add .   1.4 git status ./   1.5 git pull --rebase origin t11   1.6 git commit   1.7 git push origin HEAD:refs/for/t11   1.8 git pull --rebase origin t11
    23. 查看settings中的属性:
      eg:通过android.provider.Settings.Global.putString(mContext.getContentResolver(), "ebenInputMode", ebenInputMode)来写到setting中,可以在cmd中通过如下命令获取 adb shell settings get global ebenInputMode
    24. 回退版本:
      方法一、git log后找到要回退的commitId,执行git reset --hard commitId
      方法二、复制gerrit中的“git checkout”命令,在模块中执行即可。
    25. adb shell ps -e 查看当前运行的进程
    26. adb shell dumpsys package com.ebensz.enote.widget | findstr versionName  查找版本号 。adb shell dumpsys package com.ebensz.enote.widget 查找配置信息
    27. 某个模块monkey测试命令:adb shell monkey -p com.ebensz.copybook --throttle 500 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 1000000 > D:ljhuglogmonkeycopybookmonkey.txt
    28. 在系统SystemProperties中有属性persist.sys.touristabled,通过adb 命令可以动态的修改属性,同时也可以用命令启动某个应用,如下所示:
       28.1:在SystemProperties设置属性persist.sys.touristabled的值为able:adb shell setprop persist.sys.touristabled able
      28.2:获取SystemProperties中属性persist.sys.touristabled的值:adb shell getprop persist.sys.touristabled
      28.3:通过以下命令启动应用:adb shell am start -n com.ebensz.tourist/com.ebensz.tourist.GuideFragmentActivity

    这篇文章不错:http://blog.csdn.net/hudashi/article/details/7664464
    我的GitHub:https://github.com/lelelongwang
  • 相关阅读:
    关于json字符串与实体之间的严格验证
    SQL Pretty Printer 一款值得你拥有的MSSQL格式化插件
    ABP增加记录EFCore 生成数据库脚本日志到新的txt文件
    Multiple types were found that match the controller named 'Auth'.
    sqlserver 交叉去重
    sqlserver分组排序取前三条数据
    C# 读取.resx资源文件写入到json文件中
    SqlServer根据经纬度排序
    .net core 简单定时程序
    使用游标,查询一张的数据往另外三张表里面添加数据
  • 原文地址:https://www.cnblogs.com/longjunhao/p/8605289.html
Copyright © 2011-2022 走看看