0

I am having two branches (branch-local and master, which is remote). I have made my changes in 'branch-local'. When I tried to push a commit, someone else pushed into remote master and is hence one commit ahead. Following are some commands and outputs

git branch
* branch-local
master

git log -3 --oneline
d41d364 (HEAD -> branch-local) 401 Error fix
78479c5 Changes in index.jsp
b402271 adding alert mechanism

git checkout master
20dae35 (HEAD -> master, origin/master, origin/HEAD) Correcting the json file
78479c5 Changes in index.jsp
b402271 adding alert mechanism

I want my commit on top of branch-local to be on top of mater remote. I want it to look like:

git log -3 --oneline
d41d364 (HEAD -> master, origin/master, origin/HEAD) 401 Error fix
20dae35 Correcting the json file
78479c5 Changes in index.jsp

I am very new to Git and I do not want to merge my branches as it has done multiple times in past and won't be a best practice.

Dext1232
  • 241
  • 4
  • 18
  • Have you tried rebasing your branch on master? Then the merge is a trivial fast-forward. – jonrsharpe Dec 28 '20 at 11:42
  • First you do `git pull --rebase` – phd Dec 28 '20 at 11:52
  • 1
    First pull the latest remote changes to your current working repository, i.e., ```git pull origin master``` so that ```20dae35``` will be present in your working repository, make sure you are in master branch by running ```git branch``` and run ```git log``` now you able to see ```20dae35``` now run ```git merge branch-local``` your branch-local changes will be merged to master branch, again run ```git log``` to check your changes in master branch and push to remote. – kiran Dec 28 '20 at 12:26
  • 1
    1, ```git pull origin master``` 2, ```git branch``` (branch should be in master) 3, ```git merge branch-local``` – kiran Dec 28 '20 at 12:48

0 Answers0