git, github, gitee, Commit and Push, Commit and Sync 提交,提交和推送,提交和同步之间的区别

I'm using visual studio 2019, and I'm faced with 3 options for when I commit my C# code. I need an explanation of the differences between each of the options with regards to what happens to my local repo vs. the GitHub repo.

  • Option 1 says Commit
  • Option 2 says Commit and Push
  • Option 3 says Commit and Sync
  1. Commit will simply make record of your changes that you have made on your local machine. It will not mark the change in the remote repository.
  2. Commit and Push will do the above and push it to the remote repository. This means that any changes you have made will be saved to the remote repository as well.
  3. Commit and Sync does three things. First, it will commit. Second, it will perform a pull (grabs the updated information from the remote repo). Finally, it will push.

Basically git commit "records changes to the repository" while git push "updates remote refs along with associated objects". So the first one is used in connection with your local repository, while the latter one is used to interact with a remote repository.

commit: adding changes to the local repository

push: to transfer the last commit(s) to a remote server

Commit: Snapshot | Changeset | Version | History-record | 'Save-as' of a repository. Git repository = series (tree) of commits.

Local repository: repository on your computer.

Remote repository: repository on a server (Github).

git commit: Append a new commit (last commit + staged modifications) to the local repository. (Commits are stored in /.git)

git push, git pull: Sync the local repository with its associated remote repository. push - apply changes from local into remote, pull - apply changes from remote into local.

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

 

Committing, Pushing and Pulling

Now that you've got a local copy and a copy on your GitHub account, there are four things that you'll need to know how to do in order to collaborate with SparkFun:

  • Commit - committing is the process which records changes in the repository. Think of it as a snapshot of the current status of the project. Commits are done locally.
  • Push - pushing sends the recent commit history from your local repository up to GitHub. If you're the only one working on a repository, pushing is fairly simple. If there are others accessing the repository, you may need to pull before you can push.
  • Pull - a pull grabs any changes from the GitHub repository and merges them into your local repository.
  • Sync - syncing is like pulling, but instead of connecting to your GitHub copy of the forked repo, it goes back to the original repository and brings in any changes. Once you've synced your repository, you need to push those changes back to your GitHub account.
 
 
 

REF

https://stackoverflow.com/questions/30038999/differences-between-commit-commit-and-push-commit-and-sync

https://stackoverflow.com/questions/2745076/what-are-the-differences-between-git-commit-and-git-push

https://learn.sparkfun.com/tutorials/using-github-to-share-with-sparkfun/committing-pushing-and-pulling

https://blog.osteele.com/2008/05/my-git-workflow/

原文地址:https://www.cnblogs.com/emanlee/p/15172304.html