📜  git cheat shit - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:00:55.237000             🧑  作者: Mango

Git Cheat Sheet - Shell/Bash

Introduction

As a programmer, you will likely use Git on a daily basis to manage your code projects. Git is a powerful version control system that tracks changes made to your code over time. In this cheat sheet, we will cover some of the most common Git commands that you will use in your day-to-day work.

Basic Git Commands
Init

The git init command initializes an empty Git repository in your current working directory.

$ git init
Clone

The git clone command creates a local copy of a remote Git repository.

$ git clone <repo URL>
Add

The git add command adds a file or folder to the staging area.

$ git add <file/folder>
Commit

The git commit command saves your changes to the Git repository.

$ git commit -m "commit message"
Push

The git push command pushes your local changes to the remote Git repository.

$ git push origin <branch>
Pull

The git pull command updates your local repository with changes from the remote repository.

$ git pull origin <branch>
Status

The git status command shows the current state of your Git repository.

$ git status
Branching
Branch

The git branch command lists all of the branches in your local repository.

$ git branch
Branch Create

The git branch <branch name> command creates a new branch in your local repository.

$ git branch <branch name>
Switch

The git switch <branch name> command switches to an existing branch in your local repository.

$ git switch <branch name>
Checkout

The git checkout <branch name> command switches to an existing branch in your local repository.

$ git checkout <branch name>
Merge

The git merge <branch name> command merges changes from a specified branch into your current branch.

$ git merge <branch name>
Delete

The git branch -d <branch name> command deletes a specified branch in your local repository.

$ git branch -d <branch name>
Conclusion

This Git cheat sheet covers many of the most common commands that you will use when working with Git. With this knowledge, you should be able to use Git to effectively manage your code projects. Remember to always commit changes frequently and to create branches to isolate your work when necessary. Happy coding!