git-checkout

How to pull into not-the-current-branch?

≡放荡痞女 提交于 2019-12-05 08:27:15
问题 Say my current branch is myfeature. I want to get master up to date. Both git merge git pull always merge into the current branch, as far as I can tell. Is there a way to merge changes from a remote branch (eg, origin/master) into a branch I'm not currently on (master)? I can think of one way: git stash git checkout master git pull origin/master git checkout myfeature git stash apply Is there a better one? (It's possibly my whole question is wrong: would git fetch automatically update master

What's the difference between git reset file and git checkout file?

限于喜欢 提交于 2019-12-05 00:22:30
Why is it that git allows me to reset a file? I thought I understood reset , in the sense that it was moving the HEAD ... clearly I was wrong. So, git reset sha file seems to do the same as git checkout sha file , with the exception that I see file in the index and in the working directory. It doesn't make sense to me. Can someone please explain the difference? manojlds tl;dr git reset COMMIT FILE changes only index, git checkout COMMIT FILE will change both index and working tree. git reset has very important flags of --soft , --hard and --mixed ( and --keep and --merge ) http://git-scm.com

error: git checkout-index: unable to create file

泄露秘密 提交于 2019-12-04 23:18:25
What I am trying to do is a git clone on windows, but the parent repository exists in a unix machine. Am cloning using ssh to get a clone from UNIX to windows, and I get this weird error. error: git checkout-index: unable to create file <filename> This happens during the checkout step of a git clone. Can anyone help me? The answer should be:we can't create a file named aux.c in windows! See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx Do not use the following reserved device names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5,

Get snapshot of a git repo on a particular date

守給你的承諾、 提交于 2019-12-04 22:32:40
问题 Say I have a repo with multiple banches. Is it possible to get the repo snapshot of some particular date/time using usual git foo? (We currently have code dumps every day, and I am thinking of ways to remove that) (Assuming no branches are permanently deleted, and the git commit history hasn't been played with) Edit: Interim branch merges are possible. 回答1: Beware of the @{<date>} , based on the reflog (meaning, limited by default to 90 days). See "Specifying Revisions" in git rev-parse. "git

Difference between `git branch -f <branch_name> <hash>` and `git checkout <branch_name>; git reset --hard <hash>` under a clean working tree?

喜欢而已 提交于 2019-12-04 17:11:37
问题 Up until now, I have always used git checkout <branch_name>; git reset --hard <hash> to move a branch back to an earlier commit. Then I came across this question, but the answers and comments do not explain in great detail the differences between them. Assuming I have a clean working tree, what internal differences are there between git branch -f <branch_name> <hash> and git checkout <branch_name> git reset --hard <hash> and do such differences, if any, have any subtle implications for

What's the git equivalent of “svn update -r”?

不羁岁月 提交于 2019-12-04 08:01:58
问题 I'm a recent git convert. It's great to be able to use git-svn to keep my branches locally without disturbing the svn server. There was a bug that existed in the latest version of the code. I wanted to establish a time when it worked so that I could use git bisect. I couldn't find the right command to move back in time. Thanks. 回答1: git checkout HEAD~1 This will move your current HEAD to one revision earlier. git checkout <sha> This will move your current HEAD to the given revision. Use git

git checkout tag, git pull fails in branch

空扰寡人 提交于 2019-12-04 07:27:13
问题 I have cloned a git repository and then checked out a tag: # git checkout 2.4.33 -b my_branch This is OK, but when I try to run git pull in my branch, git spits out this error: There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream new origin/<branch> I want git pull to only update the

How to get back to most recent version in Git?

旧城冷巷雨未停 提交于 2019-12-04 07:20:02
问题 I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did git checkout <previous version hash> and did what I needed to do. Now I want to get back to the newest version, but I don't know the hash for it. When I type git log , I don't see it. How can I do this? Also, is there an easier way to change versions than by typing out hashes - something like "go back two versions" or "go to the most

git checkout is not removing files that it should

一世执手 提交于 2019-12-04 06:52:25
Using a public repo, I want to get my master branch back to a certain commit from the past. I have reviewed the options and the best thing for me looks to be a simple checkout to the desired commit, then commit to the master branch. However when I do the checkout it does not remove some files that have been added into master after the specified commit hash. So for example, if I want to get back to commit aaa1 : $ cd working-copy-top-dir $ git checkout master $ git checkout -- . $ git clean -fd $ git checkout aaa1 . $ git clean -fd But at this point some files added after aaa1 are still in the

How to merge files from one branch's directory into another branch?

孤街浪徒 提交于 2019-12-04 04:28:23
Simple example. This is 'master': root - index.html - readme.md This is a branch called 'dev': root src - index.jade dist - index.html I'd like to take the index.html file (or all files, really) in the 'dist' folder of the 'dev' branch and replace or merge it with the one in the root directory of my master branch. I've tried, from master: git checkout dev dist/ But it produces this result: root dist - index.html - index.html Clearly not what I want. Is git capable of doing what I want it to do or will I just have to whip up a script? Thanks! This can be accomplished using the subtree merge