Collaborate with Peers on GitHub

Nitin Reddy
1 min readApr 15, 2022

--

If you are working in an organisation where GitHub is used as a source code hosting site, then this post will be a helpful one for you.

Nowadays, as devs, we are following some of the best practices like forking the repository from the main organisation’s account, and we come across a situation wherein you want to collaborate with your peer on a feature and you decide to push the code on the same branch.

GitHub collaboration

Some of the commands that would work on the peer’s forked repository (Can be followed in this order):-

```
git remote add theirUsername https://github.com/theirUsername/repoName
```

```
git fetch theirUsername
```
```
git checkout -b myLocalBranch theirUsername/theirBranch
```
```
git add/commit the changes
```
```
git push https://github.com/theirUsername/repoName HEAD:branchName
```
```
git pull https://github.com/theirUsername/repoName branchName
```

Hope this post will help you in better collaboration in a long run.
Happy learning !!

--

--

Nitin Reddy
Nitin Reddy

Written by Nitin Reddy

Trying to improve my writing abilities. Unraveling the World of JavaScript: Navigating the Code with a Developer's Lens 🔍💻

No responses yet