Questions tagged [git-checkout]

1

votes
1

answer
51

Views

Git: How to checkout all deleted files through whole history

I want to restore all deleted files through whole history, which means to checkout files to the commit before the commit that delete it?
bilabila
1

votes
2

answer
192

Views

If I run `git checkout -​- .` on branch. Is there any way I can get those files back?

If I have a load of uncommitted file changes and for whatever reason run git checkout -- on a file and then realise I need it back - is there any means of doing this? Have tried git checkout HEAD but I imagine HEAD is not where those files exist anymore?
cwalker
1

votes
1

answer
26

Views

Git rollback only a directory

This is the history of my last commits: (most recent) commit 349aee3, changes in /dir1 and /dir2 commit fe9a5ac, changes in /dir1 and /dir2 commit d88450e, changes in /dir1 and /dir2 commit cdcab96, changes in /dir1 and /dir2 I would like to rollback dir1 to commit cdcab96, leaving the other directo...
SctALE
1

votes
1

answer
115

Views

Missing untracked files after soft reset

Originally I had commited to the wrong branch, wanted to take that back and commit to the right one (master). I wanted to go the route that is suggested in the accepted answer from How to fix committing to the wrong Git branch? So I made a soft reset, which as I understand it, leaves the working cop...
Sandro
1

votes
1

answer
43

Views

git checkout branch without checking files

I have huge size of git repo in my local system with 10 different branches, In those 10 branch the master repository is around 2 GB. when i switch from any branch1 to master branch, Git is trying to checkout all files in local system itself, how to reduce the time here. [[email protected]_001 myrepo]$ tim...
vinoth
1

votes
1

answer
86

Views

Git status shows changes after git reset — hard, 2nd checkout — removes change

For roughly one month now, I have a strange problem with git. I work with Intellij in a large project with lots of commits, we use gerrit for code reviews and coordination. Often I have to reset local changes or use intellij to rebase my changes. For a while now rebases fail because git can't proper...
Bytewright
1

votes
1

answer
43

Views

Checkout directories from secondary remote

I have 2 remotes: origin and secondary, and I need to checkout 3 folders from the secondary remote in my local working directory. (Let's say common/one, common/two and common/three.) I do it by using that: git fetch secondary master git checkout secondary/master -- common/one common/two common/three...
Sebastien P.
1

votes
1

answer
43

Views

difference between git --git-dir checkout and git checkout

git checkout acts differently for using option --git-dir. Commands : inside_gitdir$ git checkout remote/branch outside_gitdir$ git --git-dir=/path/.git checkout remote/branch Here command 1 works well and checking out. but the command 2 shows to move files like : error: The following untracked worki...
Bhanuchander_U
1

votes
0

answer
31

Views

Silence only status output after checkout

I want to provide my own custom coloured git status via a post-checkout hook. How can I disable the default monochrome short status output that is displayed after checking out a branch? I only want to disable the status part (so I don't print it twice), but I want to keep other messsages such as: Al...
Tom Hale
1

votes
1

answer
42

Views

Recover files after a reset hard from another branch

It's a common question here and I hope you can help me also. I didn't stash anything and no commit at all. I naively 'ran' a tool that did the following to my GitHub: git branch -f another-branch git checkout another-branch git reset --hard origin/my-work git add -A . git commit -a -m 'magical updat...
1

votes
1

answer
26

Views

`git checkout [other-branch] path-to-file` does not overwrite file on current branch

I am trying to checkout files from a different branch. I'm using the command git checkout other-branch path-to-file for example: git checkout hiresnetworkbug Leaflet-Localized/SpeciesViewController.* However this does nothing to the file on my current branch. I tried to force it with -f option bu...
maddie
1

votes
0

answer
48

Views

Checking out a specific file from a specific commit gives “error: pathspec filename did not match”

I'm using git on Windows. Say I want to check out, not commit fe4fd (abbreviated to make examples shorter) but specifically file foo.html from commit fe4fd. According to the documentation I should be able to use git checkout fe4fd foo.html and that should work. Or possibly git checkout fe4fd -- foo...
AmbroseChapel
1

votes
1

answer
103

Views

How to get the changes in following scenario?

I am trying to understand how git works. So I initialized an empty repo and added a file to it as following. cd /home/adnan/workspace mkdir git-test cd git-test git init touch README git add . git commit -m 'initial commit' Now I cloned it this repo using the following sequence of commands cd /home/...
binW
1

votes
2

answer
381

Views

Writing GIT Extension Allowing files in different branches/heads to coexist in same directory

In a previous question I asked if anyone had already written a script to allow mixing files from multiple branches (or even repos) in the same directory so that they would all get committed/pulled/etc.. from their appropriate origins. Please see that post for reasons why this isn't a case where spli...
Peter Gerdes
1

votes
1

answer
1.9k

Views

Git CHMOD post-receive hook

I'm using a bare remote repository on my webserver with a post-receive hook that will automatically push my files in the public_html directory. The problem is, I'm using codeigniter and the index.php file has to be chmod 755. I changed it on the server with filezilla, but after every push the index....
24creative
1

votes
1

answer
110

Views

Modifications visible in all branches [duplicate]

This question already has an answer here: Modified files in a git branch are spilling over into another branch 5 answers When I switch to a branch, I can see modifications done in other branch ... Sample : - I'm on master - I switch to branc A - I do some modifications - status show me modified fil...
xnopre
1

votes
3

answer
202

Views

Git checkout by commit order

When I use Git checkout master~X, I will get the Xth merged commit, what I really want is the Xth real commit (not merged commits only). How can I do that? Thanks.
kambi
1

votes
1

answer
110

Views

git checkout <branchname> systematicaly modify files

This is driving me crazy and I can't find why it's doing this... git clone [email protected]:/my/working/repo.git --I don't do anything in the working copy-- git status --no modification/no file to be commited-- git checkout another_branch --I don't do anything in the working copy-- git status modified...
MaxouMask
1

votes
1

answer
81

Views

when add a file to staged area, does git save the directory info?

I am curious about git add action, so I do some test. create a index 1. git init 2. mkdir mydir 3. echo 'hello' > mydir/hello 4. find .git/objects ==> nothing 5. git add . 6. find .git/objects ==> only find one file ,by cat-file, I am sure it is hello do some change 7. rm mydir/hello get the fil...
yao
1

votes
1

answer
34

Views

Git command equivalent

is git clone -b branch1 ssh://[email protected]/project/testkit equivalent to git clone ssh://[email protected]/project/testkit cd testkit git checkout branch1 ?
Codrguy
1

votes
1

answer
107

Views

Git checkout file remove muddle

So I try to change branches and I get: error: The following untracked working tree files would be overwritten by checkout: env/local/include # many more files env/local/lib Please move or remove them before you can switch branches. Aborting So I try git rm -r --cached . as suggested by stackoverflow...
KindOfGuy
1

votes
1

answer
532

Views

CVS Update Equivalent in Git

I am new to git.So please forgive for basic question. I have couple of checkouts of repos: Folder1 is on Server1 and Folder2 is on Server2. Folder2 only 'git pull' changes. This fetches all files which is checked-in from Folder1. I want to update only specific file something like 'cvs update filenam...
MANISH ZOPE
1

votes
1

answer
312

Views

Huge Git repository checkout at post-receive hook is extremely slow

We are using Git for our project. Repository is rather huge (.git folder is about 8Gb). We are using 'git checkout -f' in post-receive hook to update working tree. The problem is that checking out of even a couple of slightly changed files takes too long, approximately 20 seconds. I've no idea why i...
user1788078
1

votes
2

answer
54

Views

How do I remove a file change from a commit that has not been pushed to origin in git?

I have a file that I accidentally added to my most recent commit. I want to remove the changes, but leave the file in the repository. That is because it is a generated sass stylesheet and I always have merge problems with it. Since the server will regenerate it anyway I would really like to just avo...
Patrick
1

votes
1

answer
2k

Views

Checkout specific directory with GIT using SourceTree

My iPhone app is currently hosted on a BitBucket repository. I would like the graphic designer in my team to be able to view and checkout the graphic assets directory and to perform commits on it without giving visibility to the whole source code. How is it possible to do it?
Claus
1

votes
1

answer
107

Views

How can I checkout specific folder and its content from a specific commit to external folder?

How do I retrieve a complete subfolder from a git (version 1.7.0.4) repository to a local folder WITHOUT checking out the whole repo in the first place? I thought that this would be the solution: git --work-tree=/home/tmp/testcheckout checkout COMMITID -- images/* Example repo structure with some di...
basZero
1

votes
1

answer
912

Views

How to checkout a remote branch, rebase it to local master and then merge with local master?

A project of mine, on GitHub, has been receiving merge requests from another person, lately. This is awesome, but I am being forced to learn how to manage these requests when conflicts arise. The first few merge requests could be automatically merged by GitHub, so I had to do nothing. The latest one...
Ryan
1

votes
1

answer
151

Views

What is git sparse checkout and what are situations where it is useful?

I am quite advanced Git user, but just now I have discovered this 'sparse checkout' possibility. I noticed various questions/answers here on SO that it is something that people coming from SVN missed in GIT, but I do not understand what is so useful about this. Can some explain in what situations th...
jasir
1

votes
1

answer
63

Views

How to leave a subfolder out of the checkout?

I am working on a machine with windows server 2003 and I have to clone the repository where the Drupal site that I am going to work with is stored. The cloning process is carried out without problems, but when it comes to perform the check out of the files I get the following error message: fatal:...
Clickhere
1

votes
1

answer
60

Views

git commit nolonger showing up in log

Yesterday I git-commited, then checked out multiple old commits and also used stash on some of them. Now yesterday's commit is no longer showing up in git log. I dont know the tree-ish but i know the exact comment i used. I tried checking out the most-recent before yesterday's commit but it still...
ben
1

votes
1

answer
41

Views

Git: Check out all files that ever existed in a subdirectory?

Is there a way to check out all files that EVER existed in a git subdirectory? (newer ones may overwrite older ones...)
Mebus
1

votes
1

answer
1.1k

Views

Git hook creation - You are on a branch yet to be born

So im setting up a git and following this guide http://toroid.org/ams/git-website-howto. I get as far as this command: # GIT_WORK_TREE=/home3/trncprop/public_html/tpcapp git checkout -f And get the following error message fatal: You are on a branch yet to be born Does anyone know what I am doing wro...
littleswany
1

votes
1

answer
107

Views

an empty .git/info/sparse-checkout is not the same as a missing one, but the opposite, why?

First core.sparsecheckout is set to true. And I created an empty .git/info/sparse-checkout file. This causes I'm not able to checkout a new branch recently fetched from remote. Then I tried to delete the empty .git/info/sparse-checkout file, and now I can checkout. I understand the fact, and I know...
ryenus
1

votes
1

answer
42

Views

Git - edit files in branch while checking diffs

I have two branches in my git repository: master and testing. I've set up Meld as my difftool so that when I do: git difftool master..testing it opens up and shows me file by file the diffs between those branches. The scenario is: I've made some work on my master branch and I want to see how much it...
Gabriel
1

votes
2

answer
52

Views

is it possible to run a command before git checkout

every user is logged in with credentials working on a local repo he created branch. So if that user's path is shared with other anyone probably can navigate to that path and type git checkout . that would undo all the changes done by the user sitting on different machine with different login but ha...
Ciasto piekarz
1

votes
1

answer
35

Views

How to test a version of an app from a dedicated branch on a remote server?

Locally I have checked out a new branch, changed code of my app, committed these changes into that new dedicated branch. Now I would like to test this version of my app on a server. How may I do it? Usually my workflow is as follows. Locally I have two branches: dev and master. I write code in a dev...
Green
1

votes
1

answer
119

Views

Check commit where a file's history was lost

I have lost some commits in a file. If I check the history of the project, the commits are there, but they are not in the file's history. I suspect that a team member used git reset on the file in a merge conflict, loosing the history in the reset, but I am not sure. How can I find in which commit a...
Ariel Alvarez
1

votes
2

answer
851

Views

Checkout second Git branch without losing local changes

I have checked out a particular branch from my master. I created new classes propery files etc. in my local Eclipse and did the testing. I have not added/committed those classes/files to my local git repo. So after this successful prototype testing if I want to switch to another branch, how can I do...
user721025
1

votes
1

answer
354

Views

Missing commits after switching back and forth between branches

I am new to git so please bear with me. On my local repo, I've been working on this branch for a while with many commits. I haven't really pushed in a while because I am the only one working on this project. Today I finally decided it might be time to merge the development branch into the master bra...
Dzhao
1

votes
1

answer
99

Views

Is there a a way to download a branch of a remote repo without cloning first?

I just want to grab the state of a repo at a certain point in the history, but I don't want to download all the associated history of the repo (on older projects, the history can potentially be very, very long). Is there a way to do this other than a full clone and then a local checkout? I'm thinkin...
eestrada

View additional questions