Get the App
SLTechnology News&Howtos  ›  Development  › 

What Git commands should every programmer know?

Shulou Source: shulou.com Published: 2022-06-03 07:13:24 10月30日 Update

This article focuses on "what Git commands every programmer should know". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what Git commands every programmer should know.

1. Initialize the local Git repository

Git init

2. Create a local copy of the remote repository

Git clone ssh://git@github.com/ [username] / [repository-name]. Git

3. Check the status

Git status

4. Add files to the staging area

Git add [file-name.txt]

5. Add all new and changed files to the staging area

Git add-A

6. Commit changes

Git commit-m "[commit message]"

7. Delete files (or folders)

Git rm-r [file-name.txt]

8. List branches (an asterisk indicates the current branch)

Git branch

9. Create a new branch

Git branch [branch name]

10. Delete a branch

Git branch-d [branch name]

Create a new branch and switch to it

Git checkout-b [branch name]

12. Clone a remote branch and switch to it

Git checkout-b [branch name] origin/ [branch name]

13. Rename the local branch

Git branch-m [old branch name] [new branch name]

14. Switch to branch

Git checkout [branch name]

15. Merge a branch into an active branch

Git merge [branch name]

16. Merge a branch into a target branch

Git merge [source branch] [target branch]

17. Store changes in an inappropriate working directory

Git stash

18. Delete all hidden entries

Git stash clear

19. Push the branch to your remote repository

Git push origin [branch name]

20. Push changes to the remote repository

Git push

21. Update the local repository to the latest submission

Git pull

22. Extract changes from the remote repository

Git pull origin [branch name]

23. Add a remote repository

Git remote add origin ssh://git@github.com/ [username] / [repository-name]. Git

24. View changes

Git log

25. Preview changes before merging

Git diff [source branch] [target branch] so far, I believe you have a deeper understanding of "what Git commands every programmer should know". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Branch storage file command program programmer switch content learning appropriate practical deeper interest copy area practicality practical simple operation folder method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Microsoft vpn OPPO Reno