git-checkout

Strange behaviour of Git: mysterious changes cannot be undone

二次信任 提交于 2019-11-27 12:57:24
问题 I am seeing a behaviour in Git which seems very mysterious to me. I keep a clone of the Linux repository from Github to play with Git locally. To be clear, I don't do much in this repository : I fetch changes, update master , checkout a specific version, and sometimes I try out a Git GUI to see what the visualization looks like on a big project. TLDR version: I never did any changes to the files in it . Strange behaviour Earlier today, I checked-out master and pulled changes from Github.

Active Git branch is “(no branch)” on hudson CI

孤人 提交于 2019-11-27 11:17:50
问题 My Ant build.xml script starts with <property environment="env"/> <echo>GIT_BRANCH = ${env.GIT_BRANCH}</echo> <echo>PWD = ${env.PWD}</echo> Hudson CI is setup to build when any branch changes. Console output is... Commencing build of Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48) GitAPI created Checking out Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48) [workspace] $ git.exe checkout -f 90906a63929e9074035eb5b10c71ee055ad3e13c [workspace] $ cmd.exe /C '"C

What do git checkouts really mean?

前提是你 提交于 2019-11-27 10:59:28
What are checkout s in git? I know once you do checkout to a particular branch, the HEAD points to that branch. But what does it really mean? Does it mean I can then work on that branch? If yes, then, without checking out a branch, I am not able to work on it? Also, what does remote checkout mean? How is it useful? David Culp As you noted, HEAD is a label noting where you are in the commit tree. It moves with you when you move from one commit to another. git checkout <commit> is the basic mechanism for moving around in the commit tree, moving your focus ( HEAD ) to the specified commit. The

switch git branch without files checkout

南笙酒味 提交于 2019-11-27 10:09:24
Is it possible in git to switch to another branch without checking out all files? After switching branch I need to delete all files, regenerate them, commit and switch back. So checking out files is just a waste of times (and there are about 14000 files - it is a long operation). To make everything clear: I need all this to upload documentation to github. I have repo with gh-pages branch. When I rebuild documentation locally, I copy it to repo directory, commit and push to github. But I was not happy because I had two copies of documentation locally. And I decided to creaty empty branch and

“Cannot update paths and switch to branch at the same time”

隐身守侯 提交于 2019-11-27 10:08:52
I sometimes use the checkout -b option to create a new branch, check it out at the same time and set up tracking in one command. In a new environment, I get this error: $ git checkout -b test --track origin/master fatal: Cannot update paths and switch to branch 'test' at the same time. Did you intend to checkout 'origin/master' which can not be resolved as commit? Why does Git not like it? This used to work with the same repo. ' origin/master ' which can not be resolved as commit Strange: you need to check your remotes: git remote -v And make sure origin is fetched: git fetch origin Then: git

Merge, update, and pull Git branches without using checkouts

时间秒杀一切 提交于 2019-11-27 09:39:41
I work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do: git merge origin/branchB However, I would also like to keep a local copy of branch B, as I may occasionally check out the branch without first merging with my branch A. For this, I would do: git checkout branchB git pull git checkout branchA Is there a way to do the above in one command, and without having to switch branch back and forth? Should I be using git update-ref for that? How? The Short Answer As long as you're doing a fast-forward merge

Error when changing to master branch: my local changes would be overwritten by checkout

ぐ巨炮叔叔 提交于 2019-11-27 09:14:57
问题 This question is similar to this one, but more specific. I have a project with two branches ( staging and beta ). I develop on staging , and use the master branch to fix bugs. So if I'm working on staging and I see an error, I change to master branch: git checkout master and do the stuff: git add fileToAdd git commit -m "bug fixed" and then I merge with both branches: git checkout staging git merge master git checkout beta git merge beta And doesn't matter if there are other files on the

Restore file from old commit in git

人盡茶涼 提交于 2019-11-27 08:59:43
问题 I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do? 回答1: git checkout 'master@{7 days ago}' -- path/to/file.txt This will not alter HEAD, it will just overwrite the local file path/to/file.txt See man git-rev-parse for possible revision specifications there (of course a simple hash (like dd9bacb ) will do nicely) Don't forget to commit the change (after a review...) 回答2: Check out the file from your old commit via git checkout

Git: “Not currently on any branch.” Is there an easy way to get back on a branch, while keeping the changes?

懵懂的女人 提交于 2019-11-27 08:58:04
问题 So I've done some work in the repository and when I'm about to commit I realize that I'm not currently on any branch. This happens a lot when working with submodules and I am able to solve it, but the process is tedious and I've been thinking that there must be an easier way to do this. Is there an easy way to get back on a branch, while keeping the changes? 回答1: If you have not committed: git stash git checkout some-branch git stash pop If you have committed and have not changed anything

What to do with commit made in a detached head

荒凉一梦 提交于 2019-11-27 05:49:47
Using git I made something like this git clone git checkout {a rev number tree rev before} (here I started to be in a detached head state) //hacking git commit //hacking git commit (some commit where made on origin/master) git pull (which does complete because there was some error due to the fact that I'm no more on master) Because it said to me that I can still commit when in a detached head state, I did so. But now I want to like merge my detached head branch and my local master branch, and then push my bunch of changes to origin/master. So my question is how could I merge the master branch