Git Product home page Git Product logo

git-sync's Introduction

git-sync

Background

  • I want to sync my current branch (or worktree) to master, so I used
    • cd /path/to/main_worktree ; git pull ; cd /path/to/branch_worktree ; git rebase master
    • or sometimes cd /path/to/main_worktree ; git pull ; cd /path/to/branch_worktree ; git merge --ff-only master
  • But it gets tedious to write such long command everytime, so I made this script

Usage

  • Execute the script with -b branch_target option in your repository
  • usage: git-worktree-create -b branch_target [-d directory_target] [-r repository_target] [-f] [-l linked_files] [-w wait_seconds] [-v]
  • Options:
    • -b branch_target = name of main/master/base branch
    • -m mode = "worktree" or "checkout"
    • -t method = "rebase" or "merge"
    • -o options = for merge methods: "--ff-only", "--ff", "--no-ff", for rebase methods: none
    • -a before = for command to be executed before git-sync (e.g.: set in .bashrc GIT_SYNC_BEFORE='git stash')
    • -a after = for command to be executed after git-sync (e.g.: set in .bashrc GIT_SYNC_AFTER='git stash pop ; git push --force')
  • will read from command line arguments, if not found then read from environment variable
    • GIT_SYNC_BRANCH_TARGET (default "master"),
    • GIT_SYNC_MODE (default "worktree"),
    • GIT_SYNC_METHOD (default "rebase"),
    • GIT_SYNC_OPTIONS (default "")
    • GIT_SYNC_AFTER (default "")

Installation

Automatic Installation

  • copy paste below command into your terminal:
git clone https://github.com/Kristian-Tan/git-sync.git
cd git-sync
sudo bash install.sh
  • or this one-line: git clone https://github.com/Kristian-Tan/git-sync.git ; cd git-sync ; sudo bash install.sh
  • or another one-line: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Kristian-Tan/git-sync/HEAD/get)"

Manual Installation

  • installation for all users:
    • copy git-sync.sh to /usr/bin or /bin (you can also remove the extension)
    • give other user permission to execute it
    • example:
      cp git-sync.sh /usr/bin/git-sync
      chown root:root /usr/bin/git-sync
      chmod 0755 /usr/bin/git-sync
  • installation for one user:
    • copy it to any directory that is added to your PATH variable

Uninstallation

  • just remove copied files (or just use uninstall.sh script: git clone https://github.com/Kristian-Tan/git-sync.git ; sudo bash git-sync/uninstall.sh)
  • or another one-line: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Kristian-Tan/git-sync/HEAD/remove)"

Update

  • just uninstall and then install again
  • or use update.sh script: git clone https://github.com/Kristian-Tan/git-sync.git ; sudo bash git-sync/update.sh
  • or another one-line: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Kristian-Tan/git-sync/HEAD/upgrade)"

Contributing

  • Feel free to create issue, pull request, etc if there's anything that can be improved

git-sync's People

Watchers

Kristian Tanuwijaya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.