git-checkout

Why is there a difference between `master` and `heads/master`?

。_饼干妹妹 提交于 2020-01-05 23:44:27
问题 I'm writing a shell script which switches to a specified commit, makes a copy of the index in /tmp , resets HEAD to original position, then runs a command in the temporary directory: orig_head=$(git rev-parse -q HEAD) # "refs/heads/master" git checkout "$1" # copy index to /tmp/... git checkout "$orig_head" # run command in /tmp/... However, this script gives me the same "'detached HEAD' state" message as when I run git checkout refs/heads/master : Note: checking out 'refs/heads/master'. You

Push a Git branch to remote without checking the branch out

送分小仙女□ 提交于 2020-01-05 08:35:07
问题 Is there a way to push a branch to a Git remote without checking that branch out first? Say I am on the master branch, and there is a release branch that I want to push to the remote, is there a way to push the release branch to the Git remote without having to check it out first? 回答1: Try this: git push -u origin new_branch_name 来源: https://stackoverflow.com/questions/51342767/push-a-git-branch-to-remote-without-checking-the-branch-out

Git - Where do files go when you change branches?

狂风中的少年 提交于 2020-01-03 17:08:02
问题 Just beginning to learn about git and I love the concept of it. There's one thing that is a bit weird to me so far that I can't seem to find in a search. When I type git checkout branchName to change to whatever branch I want to, when I look at the Finder window I can visually see files/folders appear or disappear in the repo based on what branch I'm in. The 2 images below showcase how I am in one branch and then go to a different branch (This is from doing a Lynda.com course). The left side

Git checkout just a subdirectory

▼魔方 西西 提交于 2020-01-03 03:09:08
问题 Please note: I am not looking for git sparse checkout, nor is this question a duplicate of Is there any way to clone a git repository's sub-directory only? In git, is it possible to clone or checkout just a subdirectory, into the current directory? In svn, you would do this by extending the URL. For example, instead of checking out http://server/repo you would checkout http://server/repo/subdir The difference between sparse checkout and checking out only a subdir, is that a sparse checkout

Git checkout to external work tree and remove deleted files

时光怂恿深爱的人放手 提交于 2020-01-02 05:27:13
问题 We want to use Git to deploy code on our webserver. Therefore, we have a initialized a bare repository on our production server. Whenever we release a new version, we perform a git checkout into the DocumentRoot of the website: git --work-tree=/path/to/webroot/ checkout -f master In the subdirectories of webroot , there are several files which are not tracked by Git (Cache files, user-uploaded files etc.). These must of course not be deleted by Git when performing the checkout (and this part

How to achieve 'pre-checkout' hook in Git/bitbucket?

爱⌒轻易说出口 提交于 2020-01-01 08:27:15
问题 Result of lots of searching on net is that pre-checkout hook in git is not implemented yet. The reason can be: There is no practical use. I do have a case It can be achieved by any other means. Please tell me how? Its too difficult to implement. I don't think this is a valid reason Here my problem is: I have implemented the pre-commit , post-merge & post-checkout hooks for maintaining the database backup different for each branch. Scenario : Now when I commit the backup of database is saved

GIT checkout except one folder

邮差的信 提交于 2019-12-31 10:41:54
问题 I want to checkout to other branch, or previous commit, but I want to keep one folder the same files (not checkout the folder). I want that the folder, will be shown in git status , so I can add this folder now to the index. For example, I have a folder with node_modules . I want the folder to be in all my commits (I know that most of the people prefer to .gitignore the node_modules folder). But when I move to other commit, or checkut other branch, I want that git will not touch the node

GIT checkout except one folder

三世轮回 提交于 2019-12-31 10:41:24
问题 I want to checkout to other branch, or previous commit, but I want to keep one folder the same files (not checkout the folder). I want that the folder, will be shown in git status , so I can add this folder now to the index. For example, I have a folder with node_modules . I want the folder to be in all my commits (I know that most of the people prefer to .gitignore the node_modules folder). But when I move to other commit, or checkut other branch, I want that git will not touch the node

To git checkout without overwriting data

给你一囗甜甜゛ 提交于 2019-12-31 09:09:32
问题 How can you git-checkout without overwriting the data? I run git checkout master I get error: Entry 'forms/answer.php' would be overwritten by merge. Cannot merge. This is surprising, since I did not know that Git merges when I git-checkout . I have always run after the command separately git merge new-feature . This seems to be apparently unnecessary if Git merges at checkout. 回答1: Git is warning you that forms/answers.php has changes in your working copy or index that have not been

Visual Studio 2015 Git error message “Cannot pull/switch because there are uncommitted changes”

我是研究僧i 提交于 2019-12-31 08:34:21
问题 I am having difficulty in doing a pull from origin . I keep getting: "Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details." This also applies to switching branches. I get a similar sort of message, but this does not always happen. I am using Visual Studio 2015 Update 1 and Visual Studio Team Services Git. On my machine I have a local master branch, and development branches. Every time I switch to master and