1

I'm working on one of the cakephp website, where i use git as a version controller. I have 2 types of different branches are there :

1) development
2) ui

When i try to push my latest changes from development to ui branch using this command : git push web ui, below message will displayed.

Counting objects: 43, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (28/28), done.
Writing objects: 100% (29/29), 66.67 KiB | 0 bytes/s, done.
Total 29 (delta 15), reused 0 (delta 0)
remote: Already on 'ui'
remote: ----------------------------------------------------------------
remote: Deployed ui to Leo
remote: ----------------------------------------------------------------
To ssh://git@wasteaccountant.com/srv/git/wa.git
   bdc7d80..01e85ea  ui ->ui

but when i checked on git server for ui branch, no updates are there on that particular branch. but i can see the changes applied when i check in browser.

Updated Question:

Below are the steps of commands i used to run:

1) git status

2) git checkout development // name of development branch

3) git add

4) git commit

5) git push // pushing development changes on development branch only

6) git checkout ui // name of ui branch

7) git merge development

8) git push web ui // pushing changes on ui branch

Whatever i push on development branch i can see all changes with commit very well on git repository, but no luck for ui branch.

Note: It will working fine if i use git push -f command. very strange for me!

--------------------------------------------------------------------------------------------------

can anybody suggest me what to do? or where i made a mistake in commands?

Thanks!

Chandresh M
  • 3,808
  • 1
  • 24
  • 48

2 Answers2

2

When I try to push my latest changes from development to ui branch using this command :

git push web ui

Pushing a branch to another would be:

git push web development:ui

The first push will:

  • push the commits, and
  • update the remote ui commits with new commits done on the local ui branch (meaning 0 commits here, since you have done commits on the development branch)

However, in your case, you are pushing the ui branch updated with dev commits after meging dev into ui, so it should work.

But: if it only works after a git push -f, that means the first push should fail because of a "non fast-forward push".
A subsequent push (after yet another merge from dev to ui) done after push -f should then work.


now its working without any other very hard command, but just with git push. Again feeling strange! do you know the reason?

If your local and repo commit share the same history (which should be the case after a git push -f), then any subsequent push will add to that history (no need to force it).
So this will work:

git push origin ui

Actually, if you have set an upstream branch (through a git push -u origin ui, check it with a git config branch.ui.remote), then this will work:

git push

(check your push policy though)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your answer, but not working, i have just tried this. Same situation! – Chandresh M Dec 09 '13 at 14:14
  • @Chandresh can you tell me if the log still ends with a `bdc7d80..01e85ea ui ->ui`? (different SHA1 of course) It should display a `development ->ui`. Or it refuses to update `ui`, because it is the current branch, and only a bare repo would accept to update `ui` (http://gitolite.com/concepts/bare.html). – VonC Dec 09 '13 at 14:17
  • Yes, its displaying **development ->ui**, but when i checked that branch from git URL, result the same. its not updating with my latest changes/commits! – Chandresh M Dec 09 '13 at 14:29
  • @Chandresh yes, I suspect it is because by default a non-bare git repo **won't update the current branch**. A bare repo and a post-receive hook would work better: http://stackoverflow.com/a/20312097/6309 – VonC Dec 09 '13 at 14:31
  • Please check my updated question for my steps of commands i used to run. – Chandresh M Dec 10 '13 at 04:54
  • @Chandresh if you are still pushing to a non-bare repo, my previous comments still stand. – VonC Dec 10 '13 at 07:27
  • Hi @Vonc, now its working without any other very hard command, but just with **git push**. Again feeling strange! do you know the reason? if yes can you please explain. – Chandresh M Dec 11 '13 at 10:06
1

Try to do git reset --hard on your server. When you push to remote non-bare repo, branch is not check-outed. When you do git reset --hard, it will drop all changes it sees in the working directory, effectively moving forward to last commit. You can than put git reset --hard to post-fetch hook on your server.

jasir
  • 1,461
  • 11
  • 28