Pull and replace an existing file

I want to bring the branch (leading branch) to the current repository and replace the existing file, and not just merge the file, the command is git pullnot suitable for my needs, how to do it?

+5
source share
4 answers

Why do you think this is not suitable?

git pull will update your branch to the same state of the remote repository, so if you have a file with a newer version on the remote control, it will be replaced.

EDIT

If after pulling merges are performed with your local changes, you can reset to the state of the remote repository with the following:

git reset origin/head -- <file-path>
+6
source

If you want to replace a single file, you can use it.

git checkout -- filename

+5

, , , , ?

, (.. push pull ), HEAD , .

NB. , git fetch, git status , . , .

0

, - , , , .

git checkout - (double dash), then file name, space between double dash and file name

git checkout - [file name in repo, including path]

Example: git checkout - views / userEditor.pug

Less philosophy, more relevant help. Sheesh.

-1
source

All Articles