Q:

Unable to create a patch after modify remote with git set-url

I need to create a patch to submit changes that I made to an application.
What I did so far:

git clone https://github.com/someapp
Modified remote to my bitbucket account.
Made modifications and committed everything
Pushed all modifications to bitbucket
Modified remote back to original repository
Attempted creating patch using git format-patch origin/master --stdout. This command generates no output

How would I generate a patch in this situation? I can see all commits when I do git log

A:

Let me illustrate what you did. When you cloned the GitHub repo, origin/master and the local master branch, both point at some commit. Let's call it A. Now let's say that after you changed the URL for the origin remote, you made one commit B and pushed it. Now origin/master and master both point at commit B. When you change the URL of origin back to the original GitHub repo, origin/master still points at commit B. So your attempt to create a patch gives no output because there are no differences between your local master and origin/master.
Remember that origin/master is a "remote tracking branch". While remote tracking branches are intended to reflect the branch on a remote, they are stored locally. When you change the URL of the remote, strange things can happen like what you have seen.
One solution is to add two different remotes to your repository. That way you can track both the master of your BitBucket repo and the master of the original GitHub repo.

