编程知识 cdmana.com

Git pit entry

Now list about Git Some commands in :

Install well git The first thing after is to configure git Parameters
$ git config --global user.name "ShaoJie"
$ git config --global user.email xxx@xx.com
see git Parameters
$ git config --list
obtain git help ( It turns out that it doesn't seem to work , But no networking )
$ git help config

Clone existing warehouse

$ git clone  Project address 
---  Take an alias 
$ git clone  Project address  nickname

View the status of the current file

$ git status
----
 Status overview 
$ git status -s
Tracking files
$ git add  File name 
Ignore files
 Add ignore file 
$ touch .gitignore( Created profile name )
----- The rules 
 Format specification :
 All blank lines or with  #  The first row will be  Git  Ignore .

 You can use standard  glob  Pattern matching .

 The matching pattern can be (/) The beginning prevents recursion .

 The matching pattern can be (/) The end specifies the directory .

 To ignore files or directories other than the specified mode , You can put an exclamation point before the pattern (!) Take the opposite .

Basic commands

1. Initialize the local staging area in the working directory

$ git init Will be created under the current work package .git Folder

2. Clone from an existing repository

Clone command format :git clone [url]

for example :$ git clone git@gitee.com:oschina/git-osc.git

Copy the data in the warehouse to the local bad environment . You can rename the local warehouse when cloning the warehouse

$ git clone git@gitee.com:oschina/git-osc.git mygit

3. Add files to staging area

$ git add File name

notes : Use git add -A or git add . All changes to the current warehouse can be submitted .

$ git add -A Add a single file to the staging area

$ git add . Add all files to staging area

4. View the submission status of the current warehouse

$ git status -s

5. Submit files from the staging area to the staging area -m What follows is a note

$ git commit -m " remarks "

6. View submitted logs

$ git log

$ git log --oneline View simple log

7. View the status of the staging area

$ git status

8. Check out the comparison

$ git diff

9. Delete file
$ git rm  File name 
----- Force file deletion 
$ git rm  File name   -f
10. File rename

$ git mv Original file name modified file name

Branch command

Interact with remote warehouses

stay Github Create repository

1. Associated remote warehouse

$ git remote add origin Project address

$ git remote add origin git@github.com:xingpenghu/t1.git

2. Submit to remote repository

$ git push origin master

3. View the current remote repository

$ git remote

4. View the current remote repository

$ git remote -V

5. Download new branches and data from the remote warehouse

$ git fetch

6. The remote warehouse extracts the data and attempts to merge it into the current branch

git merge git push alas branch

7. Push to remote warehouse

$ git push origin master

8. Add from remote warehouse

$ git remote add origin2 it@pithub.com:xingpenghul/t1.git

9. Delete remote repository

$ git remote rm

10. Update remote warehouse to local

$ git pull origin Branch name

11. Delete remote warehouse Branch

$ git push origin –-delete Branch name

12. Go back to the previous version

$ git reset --hard HEAD

13. Change submission address
-- Delete the original submission address 
$ git remote rm origin
git branch --set-upstream-to=origin/ The name of the remote branch   The name of the local branch   
14. Delete file
git rm -r --cached  fileName

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[Shao Jie]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/08/20210809183600828a.html

Tags git pit entry
Scroll to Top