zoukankan      html  css  js  c++  java
  • Two scripts work with git pull/push

    作为一个程序员,工作中总是会用到一些tool,而且经常会自己开发一些tool。我的地盘,我做主。对于这些tool的版本控制,我选择的是git (公司用的是perforce)。我的代码库是通过dropbox在家里和公司同步的。开发时总是从dropbox上拿最新的版本,git里管这个叫pull。开发结束,再把代码同步到dropbox上,git里这叫push。

    push和pull这两个command运行的时候,需要你在代码库的根目录下运行(根目录下有个.git文件夹)。

    根据这个特点,我就写了下面两个script:

    pullme.bat(从dropbox-p:\repository-上拿最新代码)

       1: @echo off 
       2:  
       3: :POPCD
       4: if exist .git goto SYNC
       5: cd ..
       6: goto POPCD
       7:  
       8: :SYNC
       9:  
      10: git pull p:/Repository
      11:  
      12: @echo Now you are working with the latest copy
      13:  
      14: pause

    pushme.bat(把代码同步到dropbox上)

       1: @echo off 
       2:  
       3: SETLOCAL ENABLEDELAYEDEXPANSION
       4: SETLOCAL ENABLEEXTENSIONS
       5:  
       6: :POPCD
       7: if exist .git goto SYNC
       8: cd ..
       9: set PWD=%CD%
      10: goto POPCD
      11:  
      12: :SYNC
      13:  
      14: p:
      15:  
      16: cd p:/repository
      17:  
      18: git pull %PWD%
      19:  
      20: @echo Now p:/repository is up-to-date
      21: pause

    哥们,看出这两个脚本的方便之处了吗?

    方便之处在于:当你当前处于<root>/A/B/C/…,你没有必要不停的cd..,直到<root>。这么simple and boring的事情,交给script做吧。

  • 相关阅读:
    Outdated Kotlin Runtime
    安装 intelliJ idea 。 快速学会kotlin
    配置lambda
    kotlin 安装 使用
    android stuidio 导入项目问题。
    下载 ....aar jitpack.io 打不开。
    android studio 汉化包 美化包
    安卓架构 视频
    剑指offer-把二叉树打印成多行
    剑指offer-整数中1出现的次数(从1到n整数中1出现的次数)
  • 原文地址:https://www.cnblogs.com/jalenwang/p/pull_push_me_for_git.html
Copyright © 2011-2022 走看看