0% found this document useful (0 votes)
17 views

Simple Guide to Team Git Collaboration

Uploaded by

pavan p
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Simple Guide to Team Git Collaboration

Uploaded by

pavan p
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Simple Guide to Team Git Collaboration

Workflow for Team Members

Cloning and Setting Up :

Note: install necessary modules if required with below command after clone .
❖ npm install

Check Available Branches:

After cloning, the default branch (usually main) is checked out. Team members can confirm
all branches are available:

Switch to your team branch:


Check out the branch assigned to the team (e.g., team-1 or team-2 etc.):
Pull the Latest Changes:
Ensure the local branch is updated with the latest changes from the remote branch:

Working on a Feature Using Personal Branches:

Create a Personal Branch: Create a personal branch from the team branch for your
task:

Work on the given Feature , Make changes to the assigned files & Test locally.

Stage and Commit Changes:

Once after you completed the task , Stage and commit your changes:

Push the Personal Branch :


Creating a Pull Request (PR) to Merge into Team Branch

Create the PR:

● Go to the GitHub repository.


● Select the feature/<task-name> branch as the source and team-1 as the target.
● Provide a descriptive title and summary of the changes.

1.

2.
3.

Review and Merge:

● Team members or leads review the code.


● After approval, merge the personal branch into the team-1 branch.
Delete the Personal Branch:
After merging, delete the branch locally and remotely:

Example:remote-delete
Syncing Before Starting New Work:
Repeat the steps 😁
1. Switch to the team branch or main (to get latest code in that particular branch )
2. Pull the latest change
3. Stage changes
4. Commit changes
5. Push branch
6. Solve the conflicts and create pull request

Action Command

Clone repository git clone <repo-url>

Switch branch git checkout <branch-name>

Create personal branch git checkout -b <branch-name> <base-branch>

Pull latest changes git pull origin <branch-name>

Stage changes git add .

Commit changes git commit -m "Commit message"

Push branch git push origin <branch-name>

Delete branch (remote) git branch -d <branch-name>

Delete branch (local) git branch -d <branch-name>

ADVANCED GIT COMMANDS & USAGE :

What is Git Stash?


Purpose: Temporarily stores changes in a "stash stack" and restores the
working directory to a clean state.

Use Case:

● Switch branches without committing incomplete work.


● Work on an urgent bug fix while keeping your ongoing changes safe.
● Apply your saved changes later.

Workflow Example: Using Git Stash:

Scenario: Switching Branches with Uncommitted Changes


1. You are working on the feature-x branch and have uncommitted
changes.
2. You need to switch to the team-1 branch to fix a bug in feature-y.

Steps:

1.Stash Your Changes:This saves your uncommitted changes and leaves the working
directory clean.

2.Switch Branch:switch to respected branch where u want to fix the bug

3.Fix the Bug and Commit:Make changes or solve the bug and commit

4.Switch Back and Restore Your Changes : This restores your stashed changes
and removes them from the stash stack
Advanced Use Cases :

➔ Stash Specific Files :To stash specific files instead of all changes:
❖ git stash push -m "Stashing specific files" <file1> <file2>
➔ Stashing Untracked Files :By default, untracked files are not stashed.
To include them
❖ git stash -u
➔ Stashing with a Message:Add a descriptive message to your stash
entry:
❖ git stash save "WIP: Working on the login page"
➔ Applying a Specific Stash: To apply a specific stash from the list:
1. git stash list

Example output:

stash@{0}: WIP on feature-x: abc1234 Fixing login issue

stash@{1}: On team-1: xyz5678 Adding bug fix

2.git stash apply stash@{1}

➔ See the latest stash details:


❖ git stash show
➔ Deleting a Specific Stash
❖ git stash drop stash@{0}
➔ Clearing All Stashes
❖ git stash clear

Command Description
git stash Stashes all uncommitted changes and clears the
working directory.

git stash list Displays a list of all stashed changes.

git stash apply Applies the latest stash to the working


directory but keeps it in the stash stack.

git stash pop Applies the latest stash and removes it from the
stash stack.

git stash drop Deletes a specific stash entry from the stash
stack.
git stash clear Clears all stashed entries from the stack.

git stash save "message" Adds a descriptive message to a stash entry.

git stash show Shows details of the most recent stash.

git stash show -p Shows the patch (differences) of the most


recent stash.

git stash branch <branch> Creates a new branch and applies the latest
stash to it.

Pavankumar P
Follow for More Tech and AI Tips

You might also like