Fetch the branches and their respective commits from the upstream repository.
Commits to master will be stored in a local branch, upstream/master.
$ git fetch upstream
Check out your fork's local master branch.
$ git checkout master
Merge the changes from upstream/master into your local master branch.
This brings your fork's master branch into sync with the upstream repository, without losing your local changes.
$ git merge upstream/master
$ git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
(use "git push" to publish your local commits)
If you just want to sync up without local changes, you may push it after git merge:
$ git push
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
git push --set-upstream origin master but somehow the old user is being used?
$ git push --set-upstream origin master
remote: Permission to brightzheng100/xxx.git denied to <ANOTHER/OLD USER>.
If you checked through git config --global -l or cat ~/.gitconfig but same issue remains, it's most likely caused by OSX Keychain. Resolve it by following below steps:
In Finder, search for the Keychain Access app
In Keychain Access, search for github.com
GitHub Password Entry in KeychainFind the "internet password" entry for github.com
Edit or delete the entry accordingly.
Merge PR With Conflicts
# start from master branch
git checkout master
# checkout a new branch
git checkout -b pr-merging
# add the PR in as a remote
git remote add pr-agregory999 https://github.com/agregory999/platform-automation-pipelines.git
# fetch the content
git fetch pr-agregory999
# check it out as a local branch
git checkout --track pr-agregory999/master -b pr-agregory999
# rebase pr-merging so both have same ancestor
git rebase pr-merging
# work work work
<WORK ON CONFLICTS...>
<ADD/EDIT/DELETE FILES...>
# add all changes as one shot & commit
git add .
git commit -am "Merge pull request #3 from agregory999/master"
# checkout to pr-merging and merge it
git checkout pr-merging
git merge --no-ff --log -m "Merge PR #3 from agregory999/master" pr-agregory999
# checkout master
git checkout master
# merge pr-merging with --squash
git merge --squash pr-merging
# now all changes will be displayed
git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
new file: ops-files/resource-gcs.yml
modified: vars-dev/vars-common.yml
modified: vars-pez/vars-common.yml
# add all changes in and commit
git add .
git commit -am "Merge pull request #3 from agregory999/master"
# push it
git push
#######clean up##########
git branch -D pr-agregory999
git branch -D pr-merging
git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean