Git Commands

Some Git commands

In this article I’m going to list some git commands that are frequently used

1. List the method of git:

git

2. Set the current directory as a git repository:

git init

3. Take a look at current repository status:

git status

4_1. Add change of a single file

git add $Single_File_Name

4_2. Add all changed files

git add .

5. Take a look at the differences:

git diff

6. Reset to last version:

git reset

7_1. Tell Git who you are(name)

git config –global user.name “xxx”

7_2. Tell Git who you are(email)
git config –global user.email “xxx@xx.com

8. Commit changes to Git:(xx is comments)

git commit -m “xx”

9. Ignore some file

touch .gitignore
add file name that need to be ignored to the .gitignore

10. Stop trace some file:

git rm –cached $File_Name

11. Add branch:

git branch $Branch_Name

12. Switch to the branch:

git checkout $Branch_Name

13. merge the branch:

git merge $Branch_Name

14. List the local branches:

git branch

15. Delete some branch:

git branch -d(D:force delete) $Branch_Name

16. Add remote repository:

git remote add origin $repos_address

17. Set local repos tracing remote one:

git push –set-upstream

18. Clone the repos

git clone xxx(xxx为远程地址)

19. Password free when push to remote repos:

git config –global credential.helper store

Besides, recommend a wonderful software named lazygit


Git Commands
https://dtover.github.io/2020/04/28/Git-Commands/
作者
John Doe
发布于
2020年4月28日
许可协议