[go: up one dir, main page]

0% found this document useful (0 votes)
13 views3 pages

Here Are Common Git and GitHub Commands You

This document outlines essential Git and GitHub commands for managing a React project, categorized by workflow stages such as initial setup, typical workflow, branching, pulling and merging, and cleanup. Key commands include cloning a repository, staging and committing changes, creating and switching branches, and managing dependencies for React development. It serves as a quick reference for developers to efficiently use Git in their React projects.

Uploaded by

231221
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)
13 views3 pages

Here Are Common Git and GitHub Commands You

This document outlines essential Git and GitHub commands for managing a React project, categorized by workflow stages such as initial setup, typical workflow, branching, pulling and merging, and cleanup. Key commands include cloning a repository, staging and committing changes, creating and switching branches, and managing dependencies for React development. It serves as a quick reference for developers to efficiently use Git in their React projects.

Uploaded by

231221
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/ 3

Here are common Git and GitHub commands you'll use when working on a React project, broken

down by workflow stage:

Initial Setup

bash

CopyEdit

# Clone a repository

git clone https://github.com/username/repo-name.git

# Initialize Git in your React project (if not already a repo)

git init

# Add a remote repository

git remote add origin https://github.com/username/repo-name.git

Typical Workflow

Stage, Commit, and Push Changes

bash

CopyEdit

# Check status of your files

git status

# Stage all changes

git add .

# Or stage specific files

git add src/App.js

# Commit with a message

git commit -m "Add feature X"


# Push changes to remote (main branch)

git push origin main

Branching

bash

CopyEdit

# Create a new branch

git checkout -b feature/my-new-feature

# Switch to an existing branch

git checkout develop

# Push a new branch to GitHub

git push -u origin feature/my-new-feature

Pull and Merge

bash

CopyEdit

# Pull latest changes from main

git pull origin main

# Merge another branch into current one

git merge feature/my-new-feature

Cleanup

bash

CopyEdit

# Delete a branch locally

git branch -d feature/my-old-branch

# Delete a branch remotely


git push origin --delete feature/my-old-branch

React-Specific (Local Dev)

bash

CopyEdit

# Start React development server

npm start

# Install dependencies

npm install

# Build for production

npm run build

You might also like