【Github】Github Commands CheatSheet

GitHub is a popular web-based platform for hosting and collaborating on code repositories. As a developer, you’ll be using GitHub quite often, so it’s essential to know some of the essential GitHub commands to make your work easier and faster.

In this blog post, we’ve put together a cheat sheet of some of the most commonly used GitHub commands to help you navigate and work efficiently with GitHub.


git clone

Use this command to clone or download a repository from GitHub to your local machine. The syntax for this command is:

git clone <repository URL>

git add

Use this command to add changes to the staging area. The syntax for this command is:

git add <filename>

You can also add all changes to the staging area by running:

git add .

git commit

Use this command to save changes to the local repository. The syntax for this command is:

git commit -m "commit message"

To delete the branch, the syntax for this command is:

git branch -d <branch-name>

The -d option stands for “delete.” Make sure to switch to another branch before deleting the one you’re working on.

To modify a commit message, the syntax for this command is:

git commit --amend -m "new commit message"

git push

Use this command to upload changes to the remote repository. The syntax for this command is:

git push origin <branch>

git rebase

Rebasing is a way to modify the history of a Git branch by moving commits around. This can be useful when you need to reorganize commits, squash them together, or apply changes from one branch to another.

To rebase a commit, use the following syntax:

git rebase <branch>

This will apply the changes from the specified branch onto your current branch. You may need to resolve any conflicts that arise during the rebase process.

git pull

Use this command to download changes from the remote repository. The syntax for this command is:

git pull origin <branch>

git status

Use this command to check the status of your local repository. The syntax for this command is:

git status

git branch

Use this command to create or switch to a different branch. The syntax for this command is:

git branch <branch-name>

To switch to a different branch, use:

git checkout <branch-name>

git merge

Use this command to merge changes from one branch into another. The syntax for this command is:

git merge <branch-name>

git log

git log

git reset

Use this command to undo changes made to the local repository. The syntax for this command is:

git reset <filename>

git stash

Use this command to temporarily save changes that you don’t want to commit yet. The syntax for this command is:

git stash save "message"

To retrieve the changes, use:

git stash apply

These are just a few of the most commonly used Git commands. As you continue to work with Git, you’ll come across many more commands that will help you become a more efficient developer.


Conclusion

In this post, we’ve covered some of the essential GitHub commands that you’ll need as a developer. Remember to always check the Git documentation for more information about each command and how to use them. With this cheat sheet, you should be able to navigate GitHub with ease and speed up your development process. Happy coding!

この記事は役に立ちましたか?

はい
いいえ
貴重なフィードバックありがとうございます!