Git: add vs push vs commit

后端 未结 8 769
自闭症患者
自闭症患者 2020-12-04 05:04

What is the difference between git add, push and commit?

Just a little confused coming from SVN, where \"update\" will \'add\'

8条回答
  •  Happy的楠姐
    2020-12-04 05:12

    add -in git is used to tell git which files we want to commit, it puts files to the staging area

    commit- in git is used to save files on to local machine so that if we make any changes or even delete the files we can still recover our committed files

    push - if we commit our files on the local machine they are still prone to be lost if our local machine gets lost, gets damaged, etc, to keep our files safe or to share our files usually we want to keep our files on a remote repository like Github. To save on remote repositories we use push

    example Staging a file named index.html git add index.html

    Committing a file that is staged git commit -m 'name of your commit'

    Pushing a file to Github git push origin master

提交回复
热议问题