0

I am trying to clone a repository from another git user (name him Bob). After I made some changes to the forked repository, I wish to make a pull request and allow Bob, the original git user from whom I forked the repository from, to accept and merge the changes.

However, I am not sure if Bob is making changes at the same time. How can I know if these changes are also 'synchronized' with mine, and if I can do it from the git commands?

In other words, before I hand it to Bob, I wish to ensure that I have Bob's latest version and ensure a smooth merge on his end.

Bash

$ git pull
  • Currently, when I type the following command, maybe I get the changes pulled under my changes, but in this case, could this command be a 'rebase' !?
pylos
  • 102
  • 8

3 Answers3

2

With a repository already cloned, if anybody may be making changes in the remote, you can simply type git pull followed by the name of the branch, cheking for new changes and download them:

$ git pull origin master 

Then you will have a new remote branch with your changes, to check the current remotes type:

$ git branch --all

remotes/origin/HEAD -> origin/master
remotes/origin/master

NOTE: If you or another person are modifying the same line of the same file, git may need to do a recursive strategy and you will have to solve a conflict first.

Gonzalo Cugiani
  • 459
  • 2
  • 15
2

It isn't your responsibility to manage concurrent changes in this way.

You are working on your cloned copy of the repository. You've settled on what changes you wanted to make and you've committed them to your copy.

Now, by creating a pull request (PR), you are sending a message to the original owner that your changes may be of interest. They will review the changes, and decide whether to accept or reject them. Your only responsibility is to create the PR.

If they have indeed been making changes to their repo while you had it checked out, and if their changes are incompatible, then it's their responsibility to reject your PR.

Before you submit the PR, you may sync any changes they've made to the repo into your cloned copy. That's what git pull is for, and it does make it more likely that the PR you end up submitting will be usable or acceptable.

If there have been changes made remotely which are incompatible with your changes, then the pull will fail. At that point you can try to resolve the conflicts, or email the owner to see what they were for, etc.

But while this is usually recommended, and while many repo owners may reject a PR if you didn't do git pull first, it isn't in any way a requirement for submitting a PR.

Ross Presser
  • 6,027
  • 1
  • 34
  • 66
1

the git pull is two combined commands git fetch and git merge

So, basically, you are doing a merge operation

To do a rebase you can use git pull --rebase

Gx4
  • 13
  • 4
  • no, that doesnt solve my issue. I specify that doing so is for MY the_repo not for Bobs. – pylos Nov 02 '22 at 16:58
  • This is the solution to "I would like to make sure that all changes that were made by Bob are now synced with mine." It pulls all the changes from Bob, attempts to merge (sync them) with yours in your local repo, after which you are free to push the updated copy upstream. – zr0gravity7 Nov 02 '22 at 17:09