My branch shows its 110 commits ahead of the master branch which I have not made myself. how can I go on to work on a ticket with these commits? won’t they mess me up?
Insookwa@DESKTOP-4T543HR MINGW64 ~/openmrs-core (master)
$ git remote add upstream https://github.com/openmrs/openmrs-core.git
fatal: remote upstream already exists.
Insookwa@DESKTOP-4T543HR MINGW64 ~/openmrs-core (master)
$ git pull --rebase upstream master
From https://github.com/openmrs/openmrs-core
* branch master -> FETCH_HEAD
Already up to date.
Insookwa@DESKTOP-4T543HR MINGW64 ~/openmrs-core (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 110 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
@insookwa try to do a git reset --hard upstream/master( this will delete all your local changes to master) and then do git pull --rebase upstream master
You also could probably try git reset HEAD^ --soft(this will save your changes, back to the last commit)
or
git reset HEAD^ --hard(Discard changes, back to last commit)
i get this
Insookwa@DESKTOP-4T543HR MINGW64 ~/openmrs-core (master)
$ git reset --hard upstream/master
HEAD is now at aed41971cc TRUNK-5941: Removing nested blocks from single statement lambdas,using method references where applicable (#3547)
Insookwa@DESKTOP-4T543HR MINGW64 ~/openmrs-core (master)
$ git pull --rebase upstream master
From https://github.com/openmrs/openmrs-core
* branch master -> FETCH_HEAD
Already up to date.
i have used git reset --hard origin/master and my brach was up to date with master/origin. but when i do $ git pull --rebase upstream master i become 110 commits ahead of the origin/master
just do “git push origin master” ,to update your origin/master branch with the latest changes/commits you pulled from the Upstream master with this git pull --rebase upstream master .
I may be a little late on this one! but every time a PR is merged into the openmrs-core repository, your openmrs fork goes N-commits behind, thus the message This branch is N commits behind openmrs:master. Therefore, before working on any ticket(s), it is advisable to pull the most recent changes from the upstream branch.
git checkout master
git pull --rebase upstream master
git push --force-with-lease origin master
At this point, the message is; This branch is even with openmrs:master.
On the other hand, if you have worked on N-number of tickets and committed the changes to the local/remote master repository, the git status command will show the dreaded This branch is N commits ahead of openmrs:master. message (Considering one commit per ticket).
git reset --hard HEAD~N, where N is the number of commits.
(master)$ git pull
(master)$ git checkout -b my-feature
# make changes
(my-feature)$ git add [changed files]
(my-feature)$ git commit
# repeat the above as needed
(my-feature)$ git fetch origin
(my-feature)$ git rebase origin/master # try --interactive some time, it's fun
(my-feature)$ git push [origin|upstream|fork] my-feature
# open a PR, repeat add/commit/fetch/rebase/push as needed
(my-feature)$ git checkout master
(master)$ git pull
# and we begin again :)