git-checkout

Why does `git checkout <branch> <file>` stage the change?

蓝咒 提交于 2019-12-08 15:26:53
问题 If I start from a clean working tree and run git checkout <branch> <file> , where <branch> has a different version of this file, I end up with a staged rather than an unstaged change. What's the reason for this? Is this just for consistency with other commands like git mv , which you would expect to stage changes? Is it for convenience when using git checkout to resolve merge conflicts? Or is there some other rationale? It seems mildly odd to me since just using git checkout <branch> <file>

Git site deployment - checkout in post-receive hook not working

自古美人都是妖i 提交于 2019-12-08 11:45:09
问题 I've followed this tutorial 'Using Git to manage a web site', using Tower to commit and push my local repo to the remote server. Pushing succeeds with the following message: Pushing to ssh://user@mysite.com/~/git/tprevo.git stdin: is not a tty Counting objects: 40, done. Delta compression using up to 2 threads. Compressing objects: 100% (37/37), done. Writing objects: 100% (40/40), 171.95 KiB, done. Total 40 (delta 3), reused 0 (delta 0) To ssh://user@mysite.com/~/git/tprevo.git * [new branch

git checkout HEAD~2 (example) deletes untracked files if they were added with last commit

吃可爱长大的小学妹 提交于 2019-12-08 07:31:07
问题 I add new files (which were present before as untracked files) and commit them. When I checkout to before this commit, these files are deleted. They should not. It does not matter whether .gitignore lists these files or not (which requires to do git add -f ...). 回答1: They should not [be deleted]. Yes, they should. Commits are historical states. You're checking out a state before they were committed, so they should not be there. Just imagine working on your project a year from now. Half the

Why do I have a detached HEAD after checking out the most recent commit?

一个人想着一个人 提交于 2019-12-08 07:26:32
问题 Recently, while working in a git repository, I wanted to view the code at an old commit ( 68cce45 ), so I did git checkout 68cce45 After viewing the changes, I wanted to return to the current version of the repository and keep working. Since 2bcfd11 was the most recent commit, I did git checkout 2bcfd11 I then made some changes and did git add * and then git status which gave me the warning: HEAD detached at 2bcfd11 . I'm confused. I can understand why I would be in a "detached HEAD state" if

git checkout to a branch takes long time

…衆ロ難τιáo~ 提交于 2019-12-08 06:15:32
问题 I am on Ubuntu 17.10 and I am using git (version 2.14.1). Whenever I create a branch from master and try to checkout to it (or to the master from it), it takes a whole lot of time, around few minutes, sometimes nearly 10 minutes. True, that I have a few GBs of data, but as far as I understand, the whole data doesn't actually get copied and instead only the changes are saved. What then could be the issue behind this? 回答1: While Git 2.20 and 2.21 improve git checkout performance (see next

Checkout source files from local git repo to local folder

自古美人都是妖i 提交于 2019-12-08 05:13:41
问题 I am using Amazon Ec2 . I am trying to create a Remote Repo on the Ec2 server to which I can check in code and run my server from there . Ec2 Server Here is created two folders /home/ubuntu/project.git <---- Repo /home/ubuntu/project <---- Source files to run server I followed the instructions given here - http://blog.soarez.com/post/56644329478/deploy-a-node-js-service-on-ec2-with-git Now from my local computer , I pushed the source files to project.git . It works fine . Files get pushed

Checkout source files from local git repo to local folder

孤者浪人 提交于 2019-12-08 04:13:20
I am using Amazon Ec2 . I am trying to create a Remote Repo on the Ec2 server to which I can check in code and run my server from there . Ec2 Server Here is created two folders /home/ubuntu/project.git <---- Repo /home/ubuntu/project <---- Source files to run server I followed the instructions given here - http://blog.soarez.com/post/56644329478/deploy-a-node-js-service-on-ec2-with-git Now from my local computer , I pushed the source files to project.git . It works fine . Files get pushed into the repo. Now how do I get the files from the project.git to the project folder . I tried doing this

Git move n commits forward

让人想犯罪 __ 提交于 2019-12-08 03:24:12
问题 I'm in commit C (I just did a git checkout hash_of_C ) of a repository. A - B - C - ...<19>... - D - ...<many many commits> - Z Which Z is the last commit in the master branch Now, I want to move forward 20 commits. 回答1: If I am understanding correctly, you want to move forward 20 commits from C, and Z is the last commit on the master branch but not necessarily the 20th commit from C. From C do C > git checkout $(git rev-list --topo-order HEAD..master | tail -20 | head -1) It will checkout

How do I use octal characters in a git checkout?

故事扮演 提交于 2019-12-07 23:44:55
问题 I have a git repo of my music files, and I have recently detected that some are deleted. I suppose I accidentally deleted them, however now I have only too-briefly reveled in the fact that I had the foresight to use a git repo, so my current git status verifies they have been deleted. Here is the listing of a few: # deleted: Steve_Erquiaga-Cafe_Paradiso/03 - Arioso__J.S._Bach_.flac # deleted: "Steve_Erquiaga-Cafe_Paradiso/04 - S\303\203\302\251r\303\203\302\251nade__Rachmaninov__from_Moreaux

Can't discard changes in git

倖福魔咒の 提交于 2019-12-07 13:11:32
问题 A week or two ago I took some files that I had been archiving with a simple find |sed|tar|xz|gpg bash script, unpacked them all, and put their contents in a git repo, commited, put the next archives content in the repo, committed (rinse and repeat) in order to have a nicer system. All files were edited with on one of my two computers, both using Arch Linux, in either TeXstudio or Vim. I tried to checkout an old version, but its flipping out---it won't let me due to changed that are