Untitled

 avatar
unknown
plain_text
a year ago
2.4 kB
6
Indexable
# GitHub Commands Cheat Sheet

GitHub commands are essential for collaborating, managing repositories, and tracking changes in your projects. Here's a handy cheat sheet for some common GitHub commands.

## Basic Commands

### 1. Clone a Repository
git clone <repository_url>

css
Copy code
Clones a repository from GitHub to your local machine.

### 2. Initialize a New Repository
git init

sql
Copy code
Initializes a new Git repository in the current directory.

### 3. Check Repository Status
git status

csharp
Copy code
Shows the status of changes as untracked, modified, or staged.

### 4. Stage Changes
git add <file_name>

shell
Copy code
Stages changes, ready for commit.

### 5. Commit Changes
git commit -m "Commit message"

csharp
Copy code
Commits staged changes with a descriptive message.

### 6. Push Changes
git push origin <branch_name>

shell
Copy code
Pushes committed changes to the remote repository.

### 7. Pull Changes
git pull origin <branch_name>

shell
Copy code
Pulls changes from the remote repository to your local machine.

## Branching Commands

### 8. Create a New Branch
git branch <branch_name>

csharp
Copy code
Creates a new branch.

### 9. Switch Branch
git checkout <branch_name>

shell
Copy code
Switches to the specified branch.

### 10. Merge Branches
git merge <branch_name>

sql
Copy code
Merges changes from the specified branch into the current branch.

### 11. Delete a Branch
git branch -d <branch_name>

shell
Copy code
Deletes the specified branch locally.

### 12. Delete a Remote Branch
git push origin --delete <branch_name>

shell
Copy code
Deletes the specified branch on the remote repository.

## Remote Repository Commands

### 13. Add a Remote Repository
git remote add origin <repository_url>

shell
Copy code
Adds a remote repository.

### 14. View Remote Repositories
git remote -v

python
Copy code
Lists all remote repositories associated with your project.

### 15. Fork a Repository
Click "Fork" on GitHub web interface

go
Copy code
Creates a personal copy of someone else's project.

### 16. Pull Request
Open a Pull Request on GitHub web interface

vbnet
Copy code
Propose changes to a repository and collaborate on them before merging.

Remember to replace `<repository_url>` and `<branch_name>` with the appropriate repository URL and branch name.
Editor is loading...