0

I am a bit confused by git having previously worked with svn.

I have pulled from the main branch, created my feature branch, worked on it, added and committed my changes locally, pushed to remote and then submitted my branch to jenkins and all tests passed.

In the meantime main branch has moved on so I have checked out development, pulled the latest changes and then rebased my branch against the latest copy of development.

So this means my unit tests and integration tests ran against the latest copy of my code but not the latest copy of development.

I thought that I would now be able to push the chanegs to my remote branch again to give it the latest changes to development and then rerun my tests but git status says there is nothing to commit and that my working directory is clean.

Why is it that my branch does not recognise that there are changes to development that I might want to push to rerun my tests against?

berimbolo
  • 2,169
  • 4
  • 25
  • 57
  • "I thought that I would now be able to push the chanegs to my remote branch again to give it the latest changes to development and then rerun my tests but it says there is nothing to commit and that my working directory is clean." – This sounds suspicious. To push changes, you use `git push`. The message that there is nothing to commit comes from `git commit`. It seems you used the wrong command. – Sven Marnach May 23 '16 at 10:09
  • Well I ran git status to see if the changes were included, nothing else – berimbolo May 23 '16 at 10:10
  • You need to set up your branch to track the remote branch you are pushing to for `git status` to print any information on the relation between your local branch and the remote branch. One way of doing so is to run `git push -u -f`, which will both push your changes and set up remote tracking for you. – Sven Marnach May 23 '16 at 10:14

1 Answers1

2

A rebase completely rewrites your changes, replacing the previous commits with new ones. So you do not have anything new to commit (since your old commits were changed), but you should be able to push them again to your CI system.

Note that you may need to force-push using git push --force in order to replace the branch you have already pushed there. Do not do that outside of feature branches that you just want to have your CI run against, otherwise you will cause problems for your other team members.

poke
  • 307,619
  • 61
  • 472
  • 533
  • Why doesnt a git status on the branch show the changes that were added to develop that are now in my branch? – berimbolo May 23 '16 at 10:10
  • `git status` shows differences between the latest head, the staging area and the working directory, actually more or less the same as `svn status` does. It doesn't show you information about anything that's already committed to your branch. – Sven Marnach May 23 '16 at 10:11
  • Ok thanks, so I guess my only question now is really do I need to do a push of my branch again and rerun jenkins tests against the latest code? – berimbolo May 23 '16 at 10:12
  • If Jenkins is configured properly, it will recognize that you are replacing your feature branch with new changes and rerun the tests for it. So just pushing should work. – poke May 23 '16 at 10:38