I've been working with git for a few weeks, but now I'd like to contribute back to this open source project. I've merged my work with the latest, remote by pulling editing out conflicts and it all looks the way it should in gitk. Now I need to create a patch that is against the latest version of origin (remote) master. So I thought the following command would work:
git format-patch origin:master --stdout > 25032011.patch
but I get:
fatal: Invalid object name 'origin'.
So I've obviously got the command wrong. So how would I create a patch by comparing a specific branch on the remote with a specific local branch?
You can git branch -a to list all branches (local and remote) and then choose the branch name from the list (just remove remotes/ from the remote branch name. Example: git diff main origin/main (where "main" is the local main branch and "origin/main" is a remote, namely the origin and main branch.)
Use git branch -a (both local and remote branches) or git branch -r (only remote branches) to see all the remotes and their branches. You can then do a git checkout -t remotes/repo/branch to the remote and create a local branch. There is also a git-ls-remote command to see all the refs and tags for that remote.
Use git format-patch origin/master
. This creates a patch file for each commit on your checked out branch, which is not in origin/master.
To have one file instead of multiple files you can use
git format-patch master --stdout > mypatch.patch
Use this to create one file containing all commits in your current branch that are not in the master branch:
git format-patch master --stdout > mypatch.patch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With