DEV Community

Discussion on: How to keep your forked repository current

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

Maybe it's just me but I find it's much easier to have origin being... well the original repo and not my fork.

Before I used to clone lots of project where I actually never did any changes. What's the point?

If origin is the original repo, then I just need to checkout master and do git pull

To update a branch where I worked, I just need to do git fetch origin -v && git merge origin/master

I have some zsh aliases to help with it

export GITHUB=$HOME/github

// Usage: $ master
alias master="git fetch origin -v ; git fetch $USER -v ; git checkout -B master origin/master"

// Usage: $ clone jmfayard / buildSrcVersions 
// Will clone https://github.com/jmfayard/buildSrcVersions
function clone() {
    cd $GITHUB
    local ORG=$1 REPO=$3
    git clone https://github.com/${ORG}/${REPO}
    cd ${REPO}
    git remote add ${USER} https://github.com/${USER}/${REPO}
        echo "To fork the repository, open https://github.com/${ORG}/${REPO}/fork"
}