git-checkout

Restore a deleted folder in a Git repo

余生长醉 提交于 2019-11-28 16:47:41
I have deleted all the contents inside a folder and the folder is empty. I still had a copy in my remote repo. But when I did a git pull it didn't put back the deleted files isn't is supposed to do that? So I did some research and saw that you can revert a file by doing git checkout <revision> -- <name of file> But that only works on files. How can I retrieve all the files inside the directory? Nick Volynkin Everything you can do with a file, you can do with a folder too. Also note Find and restore a deleted file in a Git repository Files are deleted from working tree but not committed yet: If

Error when changing to master branch: my local changes would be overwritten by checkout

故事扮演 提交于 2019-11-28 15:37:12
This question is similar to this one , but more specific. I have a project with two branches ( staging and beta ). I develop on staging , and use the master branch to fix bugs. So if I'm working on staging and I see an error, I change to master branch: git checkout master and do the stuff: git add fileToAdd git commit -m "bug fixed" and then I merge with both branches: git checkout staging git merge master git checkout beta git merge beta And doesn't matter if there are other files on the working tree. But now, when I try to change to the master branch, I'm getting an error : error: Your local

git stash blunder: git stash pop and ended up with merge conflicts

时光怂恿深爱的人放手 提交于 2019-11-28 15:13:58
I did a git stash pop and ended up with merge conflicts. I removed the files from the file system and did a git checkout as shown below, but it thinks the files are still unmerged. I then tried replacing the files and doing a git checkout again and same result. I event tried forcing it with -f flag. Any help would be appreciated! chirag-patels-macbook-pro:haloror patelc75$ git status app/views/layouts/_choose_patient.html.erb: needs merge app/views/layouts/_links.html.erb: needs merge # On branch prod-temp # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified:

Restore file from old commit in git

孤街浪徒 提交于 2019-11-28 15:08:33
I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do? sehe git checkout 'master@{7 days ago}' -- path/to/file.txt This will not alter HEAD, it will just overwrite the local file path/to/file.txt See man git-rev-parse for possible revision specifications there (of course a simple hash (like dd9bacb ) will do nicely) Don't forget to commit the change (after a review...) Urs Reupke Check out the file from your old commit via git checkout [Revision_Key] -- path/to/file . Add, commit, push as appropriate. I needed to restore a recent

Git: How to update/checkout a single file from remote origin master?

我们两清 提交于 2019-11-28 14:56:06
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! qzio It is possible to do

Reuse GIT_WORK_TREE in post-receive hook to rm a few files

纵饮孤独 提交于 2019-11-28 09:15:19
I've used this 'tutorial' to set up a DSP environment: http://toroid.org/ams/git-website-howto (Yes, I don't have a T). My workflow is very easy: Develop locally ( D ) Commit a few things Commit more things Push to Staging (and Github) ( S ) Test new code on Staging Push to Production ( P ) My code contains CSS files that are minified by my code and then saved to 1 file: all.css . Locally, I've turned that option off, so I don't have to manually remove all.css all the time every time I change my CSS. On both Staging and Production, they should cache as soon as possible (so create all.css from

git checkout error: unable to create file

我怕爱的太早我们不能终老 提交于 2019-11-28 09:04:11
While cloning a git repository from Linux to a Windows system, I am getting the following error in checkout the phase: $ git clone gituser@serveraddr:/git/git_repo.git git_WA Cloning into 'git_WA'... gituser@serveraddr's password: remote: Counting objects: 500846, done. remote: Compressing objects: 100% (118676/118676), done. remote: Total 500846 (delta 307739), reused 483023 (delta 291136) Receiving objects: 100% (500846/500846), 907.54 MiB | 9.04 MiB/s, done. Resolving deltas: 100% (307739/307739), done. error: unable to create file RealR******************************************************

Pulling just one directory out of a git repo

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 07:47:24
I have a git repo that I want to do a pull from. I do a normal git pull with no problems. The issue is that I want just one certain directory out of the repo. My thinking was that I could use a .gitignore file with a rule like this: #Ignore all files / #Except the one I want !/temp The problem is this doesn't work. Is that the right way to do it or is there a better way? git pull fetches and merges the remote branch. .gitignore works only locally, and will hide matching entries from showing up on git status and being added to the index with git add . It's not what you want. What you want to do

Checkout a tag from a private GitHub repository

拟墨画扇 提交于 2019-11-28 05:36:16
问题 I need to clone a private repository from GitHub, but I only want to get a specific tag (so basically, cloning is actually the wrong term for it). Now, the problem is that there are multiple options, and all of them don't really work out: GitHub offers tagged versions as archives, but they are not accessible via curl or wget (at least I could not figure out how). GitHub does not support archiving repositories. I could run a git clone and then run a git checkout to get to the version specified

Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?

给你一囗甜甜゛ 提交于 2019-11-28 02:42:09
We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go. My problem is that it ends up with merge conflicts, and these conflicts are not easy to resolve. I don't understand why there should be any conflicts at all, since I'm just squashing commits (not deleting or rearranging). Very likely, this demonstrates that I'm not completely understanding how git-rebase does its squashes. Here's a modified version of the scripts I