Tag: git checkout

Git: pathspec 'path' did not match any file(s) known to git

I want to discard my local changes for a lot of files, which names corresponds some of wildcard pattern (for example prefix*) I tried do it with command: git checkout prefix* But got errors because of existance a local untracked files suitable for wildcards. Files are untracked because they are mentioned in .gitignore (e.g. *.log): […]

How can I avoid ignored files when I checkout a subtree branch?

I have a project with the following structure: . ├── development │   └── ignoredfile ├── .gitignore └── master └── masterfile The content of .gitignore file is development/ignoredfile Then I create a git repository and a development branch: git init . git checkout -b development git add . git commit -m “First commit” After that I […]

Can I undo (cmd-Z) a git checkout file in VSCode?

in Sublime Text, if the file was open in editor, I could Cmd-Z to a before-checkout file state after an accidental git checkout [file]. Visual Studio Code, however, seems to hard-reset the changes without any way to get back. Is that so?

How to launch a Bash function using Git alias

I want to use a Git alias in ~/.gitconfig so that it calls a bash function, if it is defined, otherwise call the regular git checkout. This is what I have devised: cat ~/.gitconfig … [alias] … co = !(compgen -A function vxzExecuteGitCheckout >/dev/null && vxzExecuteGitCheckout ) || git checkout The problem is that Git […]

Difference between `git rebase foo bar` and `git checkout bar; git rebase foo`?

I’ve seen both, and they seem to do the same thing. 1) git rebase foo bar 2) git checkout bar; git rebase foo Are they the same? And, does it depend on which branch you are on when you do 1)?

How to get just one file from another branch, but which does not exist in the current branch?

I have very a similar question to this question: https://stackoverflow.com/a/2364223/1716560 I have two branches: uk and uk-prod: git checkout uk-prod Already on ‘uk-prod’ git diff –name-status uk-prod..uk A pages/Advanced Types.md A pages/Basic Types.md A pages/Classes.md I want to get only file pages/Advanced Types.md: git checkout uk — “page/Advanced Types.md” But git throw: error: pathspec ‘page/Advanced […]

Qt Creator Git, command for checkout

I’m working on a Git-enabled Qt project and want to quickly check out some files from a previous commit. For this, although Qt Creator provides features for checking out another branch, apparently it doesn’t provide any mechanism for checking out a commit in the same branch. The only option suggested in Qt Creator is that […]

Automatically cleaning specific files between checkouts

Our project is on git, but our compilation product is not. Now, we need a way to automatically delete the compiled product (lets say kuku.exe) from the folder when we’re checking out a new branch (because it became irelevant, and we want our scripts to tell us we have to compile again). How do we […]

git-only command to restore a directory to a commit state

I would like to restore a whole directory (recursively) from the history of my git repository (exactly like this question). I know that the right git command is: git checkout [tree-ish] — path/to/the/folder But I have a problem: to restore an existing directory to the state of a commit, the content of the directory should […]

Retrieving an old version of a file using Git

Say I want to retrieve an old version of a file (filename.html) from a few commits ago. Am I right in thinking that I need to do git checkout sha — filename.html (where sha is the hash of the commit I want) But this puts the file in my staging index, and not my working […]

Git Baby is a git and github fan, let's start git clone.