This is where the git merge origin/master command comes into play. We must fetch the changes from the remote repository and merge them directly to the development branch. Since our local development branch does not have a remote tracking branch, the git pull command will not work. We have new changes in the remote master branch, and we want to bring the changes directly to our development branch without updating the master branch. Other developers working on the same project follow the same workflow. Just use git remote add origin gitip.or.domain:reponame.git on your local machine. I mean you could just do git init -bare in a directory (reponame) under the git user directory, set up sshdconfig and off you go. We have created a development branch where we make edits, merge them to the master and push them to the remote repository. I use Gitea myself and definitely recommend it or even a self-hosted GitLab CE setup over this 'hack'. In our repository, we have the master branch. However, it does not require a remote tracking branch. You will need to run the git fetch command first since your local repository is unaware of the changes in the remote repository.Ĭombined with the git fetch command, the git merge origin/master command works like the git pull command. On its own, the git merge origin/master command does not affect local branches. The git merge origin/master integrates changes from the remote master branch to the current branch. You will have to specify a remote branch in such a situation. If you have not set up a remote tracking branch for your local branch, the git pull command on its own will fail. A remote-tracking branch is a branch in the remote repository to which your local branch pulls changes from and pushes changes to. The git pull command requires your local branch to have a remote tracking branch. It will store the commit at the tip of all the remote branches. In simpler terms, Fetch_Head is the reference that keeps track of what has been fetched. Or, as I assume that you want to ultimately rebase your develop branch with the changes occured in origin/master, you can do a simple git fetch, that will not touch your local. That will update your local master with the origin/master. The git push command will fetch changes from the remote repository and invoke the git merge command to merge Fetch_Head to the checked-out local branch. If you want to update your local master without checkout, you can do : git pull origin master:master. the git pull CommandĪccording to the Git documentation, by default, the git pull command is a combination of two commands. 5) Then you can pull the GitHub repo into your local repo. 4) Then in your local repository you do a 'git remote add origin .3) In the new git hub repo you create a README. 2) You create a repository on GitHub for it. We will start by dissecting each command to derive the key difference. 1) You have an existing project n a local git repository. Difference Between git merge origin/master and git pull This is the right place if you are new to Git and struggling with the two commands. However, each command operates uniquely and has different use cases, as we will discuss shortly.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |