GIT: Difference between Pull Fetch Clone and checkout

1)      Git Pull: It will pull the file from the remote branch and merge(by default) with local branch sources. You could also provide the –rebase option to do rebase after fetching the sources.

Git checkout “localbranch”

Git pull –rebase origin master

 

2)      Git Fetch: It will fetch the sources from the remote branch and will not do the merge or rebase.

Git checkout “localbranch”

Git fetch origin master

Git merge origin master or git rebase origin master

 

3)      Git clone: It will fetch the source from the remote branch the very first time you create the repository in your local machine.

Git clone “url”

 

4)      Git checkout: It will checkout the sources from local repository unlike pull or fetch.

Git checkout “branchname”

One thought on “GIT: Difference between Pull Fetch Clone and checkout

Leave a Reply

Your email address will not be published. Required fields are marked *