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

git_operations

The document outlines popular Git commands with explanations, such as initializing a repository, staging files, committing changes, and pushing to a remote repository. It also provides a step-by-step guide for pushing all files from a local repository to GitHub. Key commands include 'git init', 'git add', 'git commit', and 'git push'.

Uploaded by

sairam91619
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)
3 views

git_operations

The document outlines popular Git commands with explanations, such as initializing a repository, staging files, committing changes, and pushing to a remote repository. It also provides a step-by-step guide for pushing all files from a local repository to GitHub. Key commands include 'git init', 'git add', 'git commit', and 'git push'.

Uploaded by

sairam91619
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/ 1

Git Operations

a) Popular Git Commands + Explanations

git init - Initialize a new Git repository locally.

git clone <repo-url> - Copy (download) a repository from GitHub to your local machine.

git status - Show the status of changes.

git add <file> - Stage a file for the next commit.

git add . - Stage all changed files.

git commit -m "your message" - Save a snapshot of staged files with a message.

git push - Send your commits to the remote repository.

git pull - Fetch and merge changes from the remote to your local branch.

git branch - List branches.

git checkout <branch> - Switch to another branch.

git checkout -b <new-branch> - Create and switch to a new branch.

git merge <branch> - Merge another branch into your current branch.

git remote add origin <repo-url> - Link your local repo to a remote GitHub repo.

git log - View the commit history.

git reset --hard <commit-id> - Reset your code to a specific previous commit.

git stash - Temporarily save changes you don't want to commit yet.

b) Push All Files from Local Repository to GitHub

1. Initialize Git: git init

2. Add all files: git add .

3. Commit changes: git commit -m "Initial commit"

4. Connect to GitHub repo: git remote add origin https://github.com/your-username/your-repo-name.git

5. Push to GitHub: git push -u origin main

You might also like