Git的使用

  1. 初始化git项目   

  2. 本地创建README.md

    Linux:

    touch README.md

    Windows:

    直接右键创建

  3. 创建.gitignore

    Linux:

    touch .gitignore

    Windows

    直接右键创建

    1. *.class  
    2.     
    3. #package file  
    4. *.war  
    5. *.ear  
    6.     
    7. #kdiff3 ignore  
    8. *.orig  
    9.     
    10. #maven ignore  
    11. target/  
    12.     
    13. #idea ignore  
    14. .idea/  
    15. /idea/  
    16. *.ipr  
    17. *.iml  
    18. *.iws  
    19.     
    20.     
    21. # temp file  
    22. *.log  
    23. *.cache  
    24. *.diff  
    25. *.patch  
    26. *.tmp  
    27.     
    28. # system ignore  
    29. .DS_Store  
    30. Thumbs.db  
  4. 执行git init

    输入git status查看情况

  5. 执行git add .

    添加文件

    输入git status查看情况

  6. 提交到本地git

    Linux

    git commit -am '注释 '

    Windows

    注释要用双引号

  7. 提交到远程仓库

    git remote add origin +git地址

  8. 查看分支

    git branch

  9. 推送

    git push -u origin master

  10. 查看远程分支

    git branch -r

  11. 创建分支

    git checkout -b v1.0(分支名) origin/master

  12. 推送分支

    git push origin HEAD -u

  修改远程仓库地址

  git remote origin set-url [url]

先删后加

git remote rm origin
git remote add origin [url]

切换分支

git checkout 分支名

删除远程分支

  git push origin --delete [branchname]




原文地址:https://www.cnblogs.com/figsprite/p/10988570.html