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
2 answers

TeamCity - clean checkout for all builds in chain

I know that when I am running a build manually, I can force it to do a clean checkout. How do I do the same for all builds in a build chain?
Martin Melka
  • 7,177
  • 16
  • 79
  • 138
0
votes
1 answer

Git checkout into a work directory with symbolic links

In this case the repository does not have symbolic links, but the working directory I am checking out into does. Why? I have an existing repository for a website. To simplify matters, let's say the directory structure for this is: bin www But…
Booboo
  • 38,656
  • 3
  • 37
  • 60
0
votes
0 answers

work independently on two git branches

I had one git branche - BRANCH-1 Following are the steps I followed: **STEP-1:** git checkout -b BRANCH-2 BRANCH-1 // creates BRANCH-2 from BRANCH-1 and switches to BRANCH-2 I make changes to some files in BRANCH-2 I do not commit **STEP-2:** git…
rumit patel
  • 1,891
  • 5
  • 23
  • 28
0
votes
1 answer

Restore deleted folder in Git correctly so files end up in current branch?

I need to restore a folder I deleted in Git but I am having trouble doing it so I end up with the folder in the correct branch. I have done: git checkout commit_id -- /path/to/folder This just puts the repo in a detached HEAD state and I am unsure…
Brett
  • 19,449
  • 54
  • 157
  • 290
0
votes
1 answer

Get content of file in some commit without using `git checkout`

Is there a way to get a full content of a file (not just diff) in some commit, without using git checkout (because it pollutes the working directory)? Something like this: $ git content 43fb721 --file main.rb => "class Main\nend\r"
just so
  • 1,088
  • 2
  • 11
  • 23
0
votes
1 answer

command git checkout deleted a few commits

I used the command git checkout 1234567 to view an old commit. Directly afterwards I checked another commit git checkout 1234568 then I checked to master again git checkout master. But now my website is on a old version. After I executed git log…
Black
  • 18,150
  • 39
  • 158
  • 271
0
votes
2 answers

Switch git branch while keeping current branch in conflicted state

I have a branch master. I created a new branch feature, made some changes to its files fileA and fileB. Meanwhile some changes were made to master also in the same files fileA and fileB. Now I merged master into feature. It shows conflicts in file…
Gaurav Kumar
  • 1,091
  • 13
  • 31
0
votes
2 answers

git rebase: weird stash behaviour

I did a git rebase -i, selected one commit for edit and git stopped at that commit. I now try to checkout one patch from the stash with git checkout -p stash. But this gives me weird old stash contents while git stash show -p gives me the…
Oliver Kötter
  • 1,006
  • 11
  • 29
0
votes
0 answers

Git has not staged and modified files after switching branch

Currently I'm struggeling with the problem, that git produces unstaged files after switching a branch with using git checkout f_refact_reg. My tree is currently looking like this: -------------------------master |------------------dev …
BendEg
  • 20,098
  • 17
  • 57
  • 131
0
votes
1 answer

cannot checkout a branch although it exists

I have 3 branches that I see in bit-bucket, one master and 2 branches other developers have worked on. I would like to take the latest branch, make a few changes, and merge it into the master. This branch is called "Updated_model_,_sources" when I…
Roman
  • 11
  • 3
0
votes
2 answers

Apply locally committed changes over pulled changes using source tree and git

I have a serious problem, I committed my local changes to the local branch. Then, I did a pull from the remote server. I then resolved the conflict. But, one mistake I did was, I accidentally accepted the change of the remote server over mine. So…
0
votes
2 answers

Undoing a git checkout --

I didn't realize that I had uncommitted changes and I ran git checkout -- 'file', is there a way to undo this?
0
votes
1 answer

Is there a way to checkout a Github repo and branch without setting up a remote?

To evaluate a pull request to our project repo seems to require doing this: git remote add newcontributor https://github.com/newcontributor/ourproject git fetch newcontributor git checkout newcontributor/pr-branch ... git remote rm…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
0
votes
1 answer

Mistakenly created a new branch and git won't pull

We have 2 branches. One is live and the other is admin. We just moved to a paid github account and I was working on live. After git push, when i type "git branch", only live shows up. I don't know why. Mistakenly, i typed "git branch admin" instead…
user3362364
  • 441
  • 11
  • 25
0
votes
1 answer

How to chown/chmod after tag checkout in git?

On a live environment I need to fetch tags and simply switch between them. After every switch, I need to chown/chmod all files inside the worktree. I've created a post-checkout hook #!/bin/bash chown -R www-data:www-data public/ find public/ -type f…
Aley
  • 8,540
  • 7
  • 43
  • 56