git-checkout

Git: can't undo local changes (error: path … is unmerged)

两盒软妹~` 提交于 2019-12-17 17:18:53
问题 I have following working tree state $ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD <file>..." to unstage) # (use "git add/rm <file>..." as appropriate to mark resolution) # # deleted by us: foo/bar.txt # no changes added to commit (use "git add" and/or "git commit -a") File foo/bar.txt is there and I want to get it to the "unchanged state" again (similar to 'svn revert'): $ git checkout HEAD foo/bar.txt error: path 'foo/bar.txt' is unmerged $ git reset

GIT: The following untracked working tree files would be overwritten by checkout

隐身守侯 提交于 2019-12-17 12:19:28
问题 I have two branches one is called master the other is called dev I am currently in the master branch and I want to go to the dev branch to move a file to the development server. however when I perform a $ git checkout dev I get the message: The following untracked working tree files would be overwritten by checkout: pages/memclub/images/subheaders/leadership.png pages/memclub/images/subheaders/male.png pages/memclub/images/subheaders/marketing.png pages/memclub/images/subheaders/training.png

How can I reset or revert a file to a specific revision?

别说谁变了你拦得住时间么 提交于 2019-12-17 07:52:49
问题 I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous version. I have done a git log along with a git diff to find the revision I need, but just have no idea how to get the file back to its former state in the past. 回答1: Assuming the hash of the commit you want is c5f567 : git checkout c5f567 -- file1/to/restore file2/to/restore The git checkout man page gives more information. If

How can I reset or revert a file to a specific revision?

懵懂的女人 提交于 2019-12-17 07:52:42
问题 I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous version. I have done a git log along with a git diff to find the revision I need, but just have no idea how to get the file back to its former state in the past. 回答1: Assuming the hash of the commit you want is c5f567 : git checkout c5f567 -- file1/to/restore file2/to/restore The git checkout man page gives more information. If

Git push error: Unable to unlink old (Permission denied)

僤鯓⒐⒋嵵緔 提交于 2019-12-17 07:00:34
问题 In the remote server I have a post-receive hook set up in order to make a git checkout of my repository: #!/bin/sh GIT_WORK_TREE=/var/www/<website> git checkout -f But when I make a push from my local machine to the git repository in the server, I get the following error messages: remote: error: unable to unlink old '<file>' (Permission denied) This appears many times over, one error message for almost every file. However I have a README.txt file that I'm able to change using git, here are

What is the difference between “git branch” and “git checkout -b”?

两盒软妹~` 提交于 2019-12-17 07:00:05
问题 I used git checkout -b to create a new branch. I think that git branch does the same thing. How do these two commands differ, if they differ at all? 回答1: git checkout -b BRANCH_NAME creates a new branch and checks out the new branch while git branch BRANCH_NAME creates a new branch but leaves you on the same branch. In other words git checkout -b BRANCH_NAME does the following for you. git branch BRANCH_NAME # create a new branch git checkout BRANCH_NAME # then switch to the new branch 回答2:

How to sparsely checkout only one single file from a git repository?

走远了吗. 提交于 2019-12-16 19:51:29
问题 How do I checkout just one file from a git repo? 回答1: Originally, I mentioned in 2012 git archive (see Jared Forsyth's answer and Robert Knight's answer), since git1.7.9.5 (March 2012), Paul Brannan's answer: git archive --format=tar --remote=origin HEAD:path/to/directory -- filename | tar -O -xf - But: in 2013, that was no longer possible for remote https://github.com URLs. See the old page "Can I archive a repository?" The current (2018) page "About archiving content and data on GitHub"

Git automatic fetch periodically/on branch checkout

浪尽此生 提交于 2019-12-16 18:05:49
问题 I would like some automated method to do a fetch from our remote origin server. So perhaps every time I switch branches git would automatically do a fetch on all branches from origin before the switch... this way when I move from a local "fix branch" to master it would tell me that my master is behind origin master. Is this possible? A more detailed reason for my requirement is below if you need to know why I want this. Thanks guys! I work in a team of developers. When I add a change to our

Difference between “checkout” and “checkout -b” when remote exists?

半腔热情 提交于 2019-12-13 05:29:40
问题 If I have a remote branch, I can locally do git checkout MyRemoteBranch and it will work fine. By work fine I mean it will create a local branch called MyRemoteBranch and switch to it, and this local will track the remote. In this case, when do I have to pass the -b parameter? What is the difference between the below when the remote does exist: git checkout MyRemoteBranch Vs git checkout -b MyRemoteBranch 回答1: Caleb's answer is correct (and I've upvoted it) but here it is in more precise

git checkout causes modified file which cannot be added

只愿长相守 提交于 2019-12-13 03:23:48
问题 I git clone my repo and git status shows everything is fine (for want of a better expression) aka no changes, etc. I then git checkout a feature branch and git status shows one file (which exists in both master and the feature branch) to be modified . git add . does absolutely nothing to change the git status and I have not made any changes to the file during the process above. The file is not git ignored. [UPDATE] I tried git add <filename> and the git status has changed from modified