-1

I am new to Git.I made a change to the branch, I committed and pushed to the remote.Now I need to make another commit & push to the same branch.

So now whether I can simply commit and push to the remote or I need to rebase the initial change with the master first and then commit & push to remote.Kindly help

Raphael
  • 1,738
  • 2
  • 27
  • 47
  • 2
    You can certainly _try_ to another `git push`. The worst that can happen is that Git will tell you that you are behind the remote. In this case, you can either rebase your branch on `master` or merge `master` into it. After this, the push should be successful. – Tim Biegeleisen Jan 21 '16 at 15:03
  • what is the correct way to do it tim? – Raphael Jan 21 '16 at 15:05
  • 1
    As I said, you can try just doing another `git push`. Go on, try it. If it doesn't go through, then come back here and post another comment. – Tim Biegeleisen Jan 21 '16 at 15:06
  • push successfull thanks. – Raphael Jan 21 '16 at 15:24
  • @TimBiegeleisen- If i want to make this 2 commits to a single commit.I need to rebase and squash it rite?whether my understanding is correct? – Raphael Jan 21 '16 at 15:30
  • 1
    Yes this sounds right. But beware, you are rewriting history and if you want to push your local branch you will need to _force_ it. If anyone else is sharing this branch with you I would advise you to not squash. However, if you are the only one using the branch then you can try this. – Tim Biegeleisen Jan 21 '16 at 15:39
  • thank you..i am only using this branch – Raphael Jan 21 '16 at 15:44

1 Answers1

1

Assuming no one else has pushed to the branch you should just be able to make a new commit and push. If you try to push and someone else has made another commit, like Tim has said, git will tell you can't, so just pull/rebase and then try again.

mohammedkhan
  • 953
  • 6
  • 14
  • If i want to make this 2 commits to a single commit.I need to rebase and squash it rite?whether my understanding is correct? – Raphael Jan 21 '16 at 15:28
  • To squash commits I'd recommend reading this: http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git/5201642#5201642 – mohammedkhan Jan 21 '16 at 16:29