What are the differences between “git commit” and

2019-01-03 00:12发布

In a Git tutorial I'm going through, git commit is used to store the changes you've made.

What is git push used for then?

15条回答
霸刀☆藐视天下
2楼-- · 2019-01-03 01:06

Three things to note:

1)Working Directory ----- folder where our codes file are present

2)Local Repository ------ This is inside our system. When we first time make COMMIT command then this Local Repository is created. in the same place where is our Working directory ,
Checkit ( .git ) file get created.
After that when ever we do commit , this will store the changes we make in the file of Working Directory to local Repository (.git)

3)Remote Repository ----- This is situated outside our system like on servers located any where in the world . like github. When we make PUSH command then codes from our local repository get stored to this Remote Repository

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-03 01:08

Since git is a distributed version control system, the difference is that commit will commit changes to your local repository, whereas push will push changes up to a remote repo.

查看更多
可以哭但决不认输i
4楼-- · 2019-01-03 01:12

git commit is to commit the files that is staged in the local repo. git push is to fast-forward merge the master branch of local side with the remote master branch. But the merge won't always success. If rejection appears, you have to pull so that you can make a successful git push.

查看更多
唯我独甜
5楼-- · 2019-01-03 01:14

git commit record your changes to the local repository.

git push update the remote repository with your local changes.

查看更多
疯言疯语
6楼-- · 2019-01-03 01:14

Just want to add the following points:

Yon can not push until you commit as we use git push to push commits made on your local branch to a remote repository.

The git push command takes two arguments:

A remote name, for example, origin A branch name, for example, master

For example:

git push <REMOTENAME> <BRANCHNAME>

查看更多
贼婆χ
7楼-- · 2019-01-03 01:15

git commit is nothing but saving our changes officially, for every commit we give commit message, once we are done with commits we can push it to remote to see our change globally

which means we can do numerous commits before we push to remote (we can see the list of commits happened and the messages too) git saves each commit with commit id which is a 40 digit code

and I use git push only when i wanted to see my change in remote (There after i will check whether my code worked in jenkins)

查看更多
登录 后发表回答