Created
January 28, 2023 10:46
-
-
Save edihasaj/778396cd084b91e47b290bd73742e85f to your computer and use it in GitHub Desktop.
Pull/Push different origin
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
# Set the new remote repository URL | |
$oldUrl = "https://github.com/your-git.git" | |
$newUrl = "https://target-git.git" | |
# Get the current directory | |
$currentDir = "C:\Users\where" | |
# Change directory to the .git folder | |
cd "$currentDir\.git" | |
# Replace the URL in the config file | |
(Get-Content config) | Foreach-Object { $_ -replace $oldUrl, $newUrl } | Set-Content config | |
# Change back to the original directory | |
cd $currentDir | |
# Perform a git pull | |
git pull | |
# Change directory to the .git folder | |
cd "$currentDir\.git" | |
# Replace the URL in the config file | |
(Get-Content config) | Foreach-Object { $_ -replace $newUrl, $oldUrl } | Set-Content config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment