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做吧。

  • 相关阅读:
    [Zjoi2006]GameZ游戏排名系统
    二逼平衡树
    郁闷的小J
    Dynamic Rankings
    数列[专杀Splay版]
    星际争霸
    半平面交
    自适应辛普森
    7月31日
    规约先行-(三)代码格式
  • 原文地址:https://www.cnblogs.com/jalenwang/p/pull_push_me_for_git.html
Copyright © 2011-2022 走看看