Last active
July 4, 2022 05:31
-
-
Save pnmcosta/0d9ff2dc4da53f2f22ea4ec05152a36f to your computer and use it in GitHub Desktop.
Git commands to fork (and rebase) from GitHub to VSTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# START Create Fork | |
# Author: Pedro Maia Costa <[email protected]> | |
# Note: Please see Gist first comment, replace <var-name> below with your values before running. | |
# fork branch into vsts | |
cd your-project | |
git init . | |
# the target <your-repo> as origin | |
git remote add origin https://<your-vsts>.visualstudio.com/<your-repo-url> | |
# the source repo <source-repo> as upstream | |
git remote add upstream https://github.com/<source-repo-url> | |
git remote -v | |
git fetch upstream | |
# creates new local <your-new-branch> from upstream/<the-source-branch> | |
git checkout -b <your-new-branch> upstream/<the-source-branch> | |
# push <your-new-branch> and set remote tracking to origin | |
git push -u origin | |
git status | |
# END Create Fork | |
# OTHER HELPERS: | |
# when you want to update your current branch from <source-repo> | |
# use upstream <the-source-branch> to rebase your current branch | |
git pull --rebase upstream <the-source-branch> | |
# if you already have a clone of <source-repo> locally | |
# switch origin url to <your-repo> | |
git remote set-url origin https://<your-vsts>.visualstudio.com/<your-repo-url> | |
# and if you already have a local branch from <source-repo> | |
# don't forget to switch branch tracking to origin/<your-branch> | |
git branch -u origin/<your-branch> | |
# if you had some changes on one of <your-repo> branches that you want rebased from <source-repo> | |
# and ensure <your-branch> is then pushed just as <the-source-branch> is use the -f argument after rebase | |
git push -f origin <your-branch> | |
# list your current remotes | |
git remote -v | |
# rebase from <source-repo> updating <your-branch> mantaining your changes | |
git rebase -Xtheirs upstream/<the-source-branch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a recent collaborator to @totaljs I want to ensure I keep my private VSTS repository always up to date with the latest from the framework. These scripts, in a VSTS Build Definition, allow me to have a workflow where I am able to dev, test and push into the private repository without affecting the public repo whatsoever.
If I want to share my work with the founders and moderators of the platform I'm also able to push to the upstream a modified branch that includes only my changes and is properly rebased and ready to merge/PR,
Notes
Screenshots
Total.js Readme in the VSTS project home

Commits from GitHub showing in VSTS

Nightly Rebase Build Definition

Allow scripts to access OAuth token
