Questions tagged [git-checkout]

Checkout a branch or file to the current working tree in a Git repo.

git checkout is used to update files in the current working tree to a specific version in the index or specified branch.

To restore a file to the version in the index:

git checkout -- <filename>

Popular questions

See also

References

$ git checkout --help
1090 questions
0
votes
1 answer

Git checkout when using submodules

I have a parent git repo with 3 branches in it. I am also using a submodule repo, that has the 3 branches with the same names, and the .gitattributes file in each branch of the parent repo points to the submodules branch of the same name. This is…
0
votes
1 answer

Listing of checkout items by user in Git

Is there any way to get listing of all check out files in git repositories by user?
0
votes
1 answer

Git: Deny create branch, if branch not created from a master

Tell me please how to deny create branch, if branch not created from a master? I was planning to do to forbid the commit if the branch is not created from the master, but clearly determine that the branch is not created by the wizard does not…
0
votes
1 answer

Jenkins Pipeline checkout not building PR commits

We are using the integrator workflow with github. I am taking over a partially set up Jenkins Pipeline build from a dev that left the team. Currently, whenever we create a PR against the master repo, Jenkins will trigger a build as defined in the…
0
votes
1 answer

How to move the ignored files too in a checkout?

I am working on a branch. There are some ignored files like for example config files and installed composer/bower packages. If I checkout to an another branch, the ignored files are still there. I would like to remove them if I check out an other…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
0
votes
0 answers

Keeping some local changes when checking out with --force

The situation: I have a local git repository which is a clone of a remote repository. Suppose the repository is tracking (among others) two files, fileA and fileB. After cloning the repository, I modify fileA and fileB locally, but I never stage or…
Lars Ebert
  • 3,487
  • 2
  • 24
  • 46
0
votes
0 answers

Can't unmodify files in git

When I merged with another branch, a few of my files became modified automatically. I tried to checkout -- on the files, but git status still shows them as modified. I then tried a custom shell function that normally fixes these kinds of problems…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
0
votes
1 answer

git checkout branch -- file vs git merge

I am concerned that git checkout other_branch -- file will overwrite the file in my current branch and not do a merge at all. Say I am on a branch called foo. I want to merge a file in foo called bar.js, with the same filepath on a branch called…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

git checkout deletes files

I am new to git and I wanted to try the branch feature. I am working with a local repository. The problem is that if I create a new branch and then go back to the master branch, some files are lost. This is what I do: I have two directories: $…
thyme
  • 388
  • 5
  • 18
0
votes
1 answer

git go back to the state of a file before conflict

I had the merge conflict while pulling from another branch and used "Use mine" instead of "Use theirs" mistakenly for a single file. the other conflicted files were taken good care. Now i want to move to the old state of this file (before conflict)…
Fast Mani
  • 171
  • 8
0
votes
2 answers

Can't cancel my update

I have a question about git command. I tried to cancel my update from git stash. But i wasn't able to do it. I use the following command. ~/xxxxx-repo on  master! ⌚ 18:27:45 $ git checkout . …
0
votes
1 answer

git double checkout, folder content gone

I have a git repository with a master and developer branch. Say my branch is called branch1. Inside my repo I have a folder called myfolder. I was on branch1 and I did git checkout master git checkout branch1 myfolder is now empty (sic), how did…
Manfredo
  • 1,760
  • 4
  • 25
  • 53
0
votes
1 answer

How to checkout the contents of a directory in git?

I have a repo with a 'htdocs` directory in its root, is it possible to checkout only the contents of this folder? I tried running: git checkout -f master -- htdocs Which does ignore everything else in the repo root but it also brings in the htdocs…
Javier Villanueva
  • 3,886
  • 13
  • 48
  • 80
0
votes
2 answers

Checked out a different branch. Why is HEAD still pointing to master branch

I checked out someone else's branch and tracking it. git checkout --track origin/foo However, even though I checked out a different branch (not the master branch), why is HEAD still pointing to master? When I type git branch -a, I get this. So I…
Mike Huang
  • 15
  • 2
0
votes
2 answers

How to get back modified file after git checkout and git pull?

I've modified a file, then I want to get latest version from remote. So I run git checkout to revert the file, and run git pull to get latest version. After that, I found that I need the modification of the file. Is it possible to get it back?…
Dong
  • 911
  • 2
  • 9
  • 25