git-checkout

Problems with corrupt git repo

戏子无情 提交于 2019-11-30 08:29:51
My git repo got corrupted while running a find and replace command (See here: Git reset failing after find and replace ). So I deleted some pack files about which git told me that there were not reachable. So I ran rm ./.git/index, git reset. When running git commit, I got this message : fatal: corrupt tree sha $someSHA Finally git fsck, my working directory went clean and I was able to commit. The pb now is that when I run git checkout some_other_branch, I got this message fatal: unable to read tree $someSHA (The $someSHA appearing are the same). Someone could help me ? Edit 1 : when I run

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

烈酒焚心 提交于 2019-11-30 06:07:22
问题 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.

Git: How do you checkout all deleted files?

梦想的初衷 提交于 2019-11-30 05:06:35
In git I am familiar with how to checkout individual files that have been deleted using the git checkout -- [<paths>...] syntax (which is recommended when you do git status . To get all the files you could create a list and give the list as the argument to the above command. However when you just want all the files that have been deleted (i.e. rm -rf in your cwd and then you want to restore all files) generating that list is inelegant. How do you checkout all deleted files? Generating the list is not that hard: git diff --no-renames --name-only --diff-filter=D To make it suitable for git

How can I print the log for a branch other than the current one?

走远了吗. 提交于 2019-11-30 04:10:52
I'm on a branch with some changes. Changing branch is a pain as some files are locked by processes, so to change branch I'd have to stop all the processes which have locks, then stash the changes before checking out the other branch to see its log. Is it possible to view the log for a different branch, without having to check it out? TL; DR Use git log <branch> where <branch> is the name of the branch of interest. From the git-log man-page... A simplified version of the git-log synopsis given in that command's man page is git log [<revision range>] Further down, you can find the following

Git change branch when file of same name is present

馋奶兔 提交于 2019-11-30 03:06:35
I have in my git repo, a file named xyz. Coincidently, I also have a branch named xyz. Presently I am on master, but I want to checkout to branch xyz. The command to be used is simple $ git checkout xyz But this would checkout the file xyz to the present HEAD. How would I change my branch to branch xyz ? As illustrated by commit a047faf (git 1.8.4.3+), you can also try: git checkout xyz -- (Note: the error message will be clearer with Git 2.21, Q1 2019 ) That would make clear that the xyz part is a branch or commit, while everything after -- must be a path (here no path is provided). See more

What is the difference between “git checkout — .” and “git reset HEAD --hard”?

会有一股神秘感。 提交于 2019-11-30 02:31:53
This is not a general question about what '--' does, as in the marked duplicate. This is a git-specific question asking for clarity on what the operational differences are between the mentioned commands. If I want to clean out my current directory without stashing or committing, I usually use these commands: git reset HEAD --hard git clean -fd A co-worker also mentioned using this command: git checkout -- . It's a difficult command to google, and it's not clear to me from the git documentation what this command actually does. It seems to be one of the later-mentioned usages in the manual. At a

error: pathspec 'test-branch' did not match any file(s) known to git

余生颓废 提交于 2019-11-30 01:17:28
I am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running git clone https://github.com/rohinichoudhary/Spoon-Knife.git This repository contains three branches, i.e. master , test-branch , change-the-title . When I run git branch , it only shows *master , not the remaining two branches. And when I run git checkout test-branch I get the following error: error: pathspec 'test-branch' did not match any file(s) known to git. Why is this happening? How can I solve this problem? jub0bs When I run git branch

git archive fatal: Operation not supported by protocol

风格不统一 提交于 2019-11-30 00:16:39
问题 I'm trying to checkout part of remote git repository. As recommended here, with help of command git archive --format=zip --remote=http://path_to_repository But I'm getting error message: fatal: Operation not supported by protocol. Unexpected end of command stream Git is not supporting this operation with http protocol? Thats a problem of hosting environment or git itself? Any directions would help, thanks. 回答1: git archive can work with a server with git protocol support (i.e. git server,

git checkout --ours does not remove files from unmerged files list

喜夏-厌秋 提交于 2019-11-29 20:29:09
Hi I need to merge two branches like this. This is just an example what is happening, I work with hundreds of files which need resolution. git merge branch1 ...conflicts... git status .... # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # both added: file1 # both added: file2 # both added: file3 # both added: file4 git checkout --ours file1 git chechout --theirs file2 git checkout --ours file3 git chechout --theirs file4 git commit -a -m "this should work" U file1 fatal: 'commit' is not possible because you have unmerged files. Please, fix them up in the

smartgit delete commit and return to previous commit

删除回忆录丶 提交于 2019-11-29 18:19:22
问题 By mistake i have made a commit that now i want to delete from the history log and return to a previous commit. I have been trying to checkout the commit that i want to return to but Smartgit ask me to create a local branch in order to do this (screen shot attached) and since im not an expert with SG i really need some advice. I have also try to revert the commit that i made by mistake but i still see the commit on the log. This is how the log look now: When trying to checkout : How my log