Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update particular folder/file from central repository in Git?

Tags:

git

repository

Is there a way to update folder or file alone in Git? I had cloned from central repository and wish to update only specific folder/files.

like image 769
baluchen Avatar asked May 26 '11 12:05

baluchen


People also ask

How do I update an existing file in git?

To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.


1 Answers

you can use git fetch to update the objects in your local clone, and then you can git checkout those particular files.

For example - if your remote is called origin and you only want to update main.c from the master branch you can do this:

git checkout origin/master main.c

This will update the file in your working directory and add it to the index ready to be committed on your local branch.

like image 120
Abizern Avatar answered Oct 19 '22 22:10

Abizern