Git merge files into working copy

I have a git repository where I store the template files that I often use, I checked the latest version a couple of days ago and made local changes to these template files.

I just made changes to the master repository of template files, and now I want to check the latest version of my main branch, but I do not want my local changes to be deleted.

How can I merge changes with the main branch into my working copy?

+3
source share
2 answers

To take full advantage of git merge (or rebase) tactics, you can commit the changes to your local repository and then pull. Pull merges between the remote and local repositories, which can be fast or recursive merges depending on upstream changes. You might even want to create a new branch for this (which you can then click on the origin if you want, without affecting the main branch).

The stock may help you here, but you risk that the wallet will not be able to apply after traction.

A simple example:

git add .
git commit -m 'My local template changes'
git pull origin master # fix any conflicts

An example of a new branch:

git checkout -b newbranch
git add .
git commit -m 'My local template changes'
git pull origin master # fix any conflicts

master newbranch, , master - (.. git checkout master, 'd - git pull, ).

+8

, .

git stash     -- save your local changes
git pull      -- get latest changes from remote
git stash pop -- apply your saved changes
+3