git-checkout

Show which git tag you are on?

偶尔善良 提交于 2019-11-28 02:39:53
I'm having trouble finding out which tag is currently checked out. When I do: git checkout tag1 git branch I can't seem to find out which tag I'm on. It only logs: * (no branch) master Is it possible to find out which tags are checked out? In the above example, this would be tag1 . bstpierre Edit : Jakub Narębski has more git-fu. The following much simpler command works perfectly: git describe --tags (Or without the --tags if you have checked out an annotated tag. My tag is lightweight, so I need the --tags.) original answer follows: git describe --exact-match --tags $(git log -n1 --pretty='%h

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

╄→гoц情女王★ 提交于 2019-11-28 02:39:05
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 HEAD foo/bar.txt Unstaged changes after reset: M foo/bar.txt Now it is getting confusing: $ git status

Git hook creation - You are on a branch yet to be born

随声附和 提交于 2019-11-28 02:11:45
问题 So im setting up a git and following this guide http://toroid.org/ams/git-website-howto. I get as far as this command: # GIT_WORK_TREE=/home3/trncprop/public_html/tpcapp git checkout -f And get the following error message fatal: You are on a branch yet to be born Does anyone know what I am doing wrong? Thanks in advance! Littleswany 回答1: That command is supposed to be in a hook, not to be executed directly in website.git $ cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/var/www/www.example

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

本秂侑毒 提交于 2019-11-28 01:47:02
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. Greg Hewgill 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 you want to revert to the commit before c5f567 , append ~1 (works with any number): git

git: checkout files from another branch into current branch (don't switch HEAD to the other branch)

核能气质少年 提交于 2019-11-27 21:47:43
I want to load a different version of the files that exist in another branch into my current branch. git help checkout says: DESCRIPTION Updates files in the working tree to match the version in the index or the specified tree. If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch. Is there a way to checkout all those files, but not update HEAD? checkout by providing the current path, . : git checkout other-branch-name -- . This operation is similar to switching HEAD to another branch without checking out files , but just from the "other

Restore a deleted folder in a Git repo

旧城冷巷雨未停 提交于 2019-11-27 19:55:24
问题 I have deleted all the contents inside a folder and the folder is empty. I still had a copy in my remote repo. But when I did a git pull it didn't put back the deleted files isn't is supposed to do that? So I did some research and saw that you can revert a file by doing git checkout <revision> -- <name of file> But that only works on files. How can I retrieve all the files inside the directory? 回答1: Everything you can do with a file, you can do with a folder too. Also note Find and restore a

Is there a difference between “git reset --hard hash” and “git checkout hash”?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:30:48
While reset and checkout have different usages most of the time, I can't see what difference there is between these two. There probably is one or nobody would have bothered adding a --hard option to do something the basic checkout can do. Maybe there is a difference is the way you will see the history? Cascabel This answer is mostly quoted from my answer to a previous question: git reset in plain english . The two are very different. They result in the same state for your index and work tree, but the resulting history and current branch aren't the same. Suppose your history looks like this,

Unstage a deleted file in git

大城市里の小女人 提交于 2019-11-27 16:37:04
Usually, to discard changes to a file you would do: git checkout -- <file> What if the change I want to discard is deleting the file? The above line would give an error: error: pathspec '<file>' did not match any file(s) known to git. What command will restore that single file without undoing other changes? bonus point: Also, what if the change I want to discard is adding a file? I would like to know how to unstage that change as well. twalberg Assuming you're wanting to undo the effects of git rm <file> or rm <file> followed by git add -A or something similar: # this restores the file status

Git, How to reset origin/master to a commit?

随声附和 提交于 2019-11-27 16:34:08
I reset my local master to a commit by this command: git reset --hard e3f1e37 when I enter $ git status command, terminal says: # On branch master # Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. # (use "git pull" to update your local branch) # nothing to commit, working directory clean Since I want to reset origin/header as well, I checkout to origin/master: $ git checkout origin/master Note: checking out 'origin/master'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in

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

£可爱£侵袭症+ 提交于 2019-11-27 14:45:50
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 I dont want to commit the files to the master, they are not ready to be pushed. First you'll want to