1

Here i m successfully run git add and git commit on my gitlab account but when i perform git push they give me a following error:

To gitlab.com:shrav/vaishaliAllProjects.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@gitlab.com:shrav/vaishaliAllProjects.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Can anyone say how to perform git pull in ubuntu terminal??

vaishali bagul
  • 51
  • 2
  • 2
  • 7

1 Answers1

3

I think the answer is to simply git pull. This will merge all changes from the origin to your local copy. You can then git add * those to stage them for commit to your own branch, git commit to actually commit to your own branch, then git push to send your changes back to the origin.

The reason you need to do this is that someone has made changes to the remote branch while you've made changes to yours. The two branches are diverged. If you just push your changes, there is no garuntee that it is compatible with the changes others have made. By performing a git pull first, you merge the remote changes with yours. You can then review those changes with git status to ensure that the merge didn't break any of your work. Only once your branch is effectively a replica of the remote one (plus your intended changes), can you git push your changes back.

Stewart
  • 4,356
  • 2
  • 27
  • 59
  • One more think was that ill perform update operation on remote branch before perform this git add. Because of this they give me an error ?? how can i solve it – vaishali bagul May 26 '17 at 05:26