Team Collaboration in Github

itzAnkitCodes01itzAnkitCodes01
3 min read

For Main account( Initial Configurations ) —-

Steps —-

1 - Create a Github Repo

2 - Open VS Code —(Make sure you have Git and Vs code in your system)

Enter these commands-

echo "# hello" >> README.md

git init git add README.md or git init git add .

git commit -m "first commit"

git branch -M main

git remote add origin https://github.com/<username>/<file>.git

git push -u origin main //if the origin is not a main , first create a main origin —

For creating main branch → git checkout -b main

To Check Branch —> git branch

If you create a new main branch , after that perform these commands -

git add .

git commit -m "Initial commit"

git remote add origin https://github.com/<username>/<file>.git

git push -u origin main

Finally , you had pushed your code —

Now beginning collaboration

For collaboration ,we will send a collaboration request to the team member(Github account)..

After accepting collaboration request ,new member is added in a project.

After that new member will able to push or pull in a github repo of main member account..

After that —

Only for collaborator (team member )(Part 1)

New member will setup the repository by using command..

git clone https://github.com/<main-member-account-name>/<file>.git

// In the code section in a github repo , you will get this above link

Never push your code to main branch , always create a new branch by using command-

git switch -C <branch-name>

Switched to a new branch <branch-name>

git branch →To check a branch .. Always check your branch before pushing your code

Suppose you make a change in a code , then how can you push ?

Follow the below steps —

git add .

git commit -m "<write changes>"

git push -u origin <branch name>

Now , your changes will pushed to branch and main member(merger) will merge the branch

Only for merger (Main person)

git branch //switch to the team member branch

git checkout <member-branch> //checkout the branch

git pull origin <member-branch> // pull files from member’s branch ,now the main person get all the source code

git switch main //Now switch to main

git merge <member-branch> //merge the branch with main branch

git push origin main // push to the main branch ,

Now the merger will see the changes in main branch in his github , but the collaborators want to pull the code from main branch to see the changes .

Only for collaborator (team member)(Part 2)

git switch main // switch to main branch

git fetch //fetch the files

git pull //pull the files

Thanks for reading this article ………….

10
Subscribe to my newsletter

Read articles from itzAnkitCodes01 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

itzAnkitCodes01
itzAnkitCodes01

Hey , I am Ankit , a passionated FrontEnd / FullStack Developer having expertise in building responsive and user-friendly websites .