Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

The scenario:

I make some changes in a single file locally and run git add, git commit and git push

The file is pushed to the remote origin master repository

I have another local repository that is deployed via Capistrano with the "remote_cache" method from that remote repository

Now I don't want to deploy the whole application but just update/checkout that single file.

Please, is this somehow possible with git? I wasn't able to find anything that would work nor was I able to figure it out. With SVN I just did svn up file and voila.

I'll be glad for any help, thanks!

3 Answers

0 votes
by (27.5k points)

It can be done in the deployed repository: 

$ git fetch

The git fetch command will download all the recent changes, but it will not put it in your current checked out code (working area).

$ git checkout origin/master -- path/to/file

Then the checkout command will update the working tree with the particular file from the downloaded changes (origin/master).

You should also read Git Tutorial and further, enroll in Git Training to get a clear understanding of the concept.

0 votes
by (37.3k points)

To update/Checkout a single file from the remote origin master, Here is the below code:

git archive --format=zip --remote=ssh://<user>@<host>/repos/<repo name>  <tag or HEAD> <filename> > <output file name>.zip

0 votes
by (1.3k points)

In Git, you can download a single file in your repository without deploying the whole application. Here's how:

Fetch the Latest Changes:

Run git fetch origin to acquire the latest updates from your remote repository.

Checkout Single File:

Use the command below to checkout the selected file from the remote in the following way:

git checkout origin/master -- path/to/your/file

It then updates just that one file in your local repository similar to what SVN's svn up file does. You can now deploy the changes with Capistrano.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...