Chandresh M
Chandresh M

Reputation: 3828

How to upload changes from development branch to remote branch on GIT?

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://[email protected]/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!

Upvotes: 1

Views: 312

Answers (2)

VonC
VonC

Reputation: 1327384

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)

Upvotes: 2

jasir
jasir

Reputation: 1471

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.

Upvotes: 1

Related Questions