Skip to content

Instantly share code, notes, and snippets.

@elfrank
Last active August 19, 2024 12:58
Show Gist options
  • Save elfrank/c08256de9c15e41e1781 to your computer and use it in GitHub Desktop.
Save elfrank/c08256de9c15e41e1781 to your computer and use it in GitHub Desktop.
How to work on someone else's branch

#How to work on someone else's branch

Let's assume you need to collaborate with Batman on his forked repository.

  • First, you need to add his fork as a remote.
git remote add batman [email protected]:batman/iambatman.git
  • Now, you can fetch, pull and push to his fork (if you have permissions to do so).
git fetch batman
  • So, to add changes to the savegotham branch, you must:
# batman is the name of the remote
git checkout -b local-branch-name batman/savegotham
# ...Make changes to local files...
git add -A
git commit -m "The joker is dead"
# batman -> name of remote, savegotham -> name of branch
git push batman savegotham

####Notes:

  • See your remotes with git remote -v
@smccarthy-ie
Copy link

Excellent, many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment