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

continue work and commits on same branch after having reverted/ reset

Man, this git thing surely is a hard nut to crack! So I have this branch: a--b--c--d - mybranch What I would do here is go back to commit 'b' and continue working and committing. but I would want to neither branch anew nor loose 'c' and 'd'…
kellogs
  • 2,837
  • 3
  • 38
  • 51
0
votes
1 answer

Commit then checkout another branch in git carries old commit?

If I am on branch b-one and I run git commit -m "init commit" and then git checkout -b b-two, does the commit carry to the new branch? More generally, are commits branch specific? Or when you commit, are you just committing on your local machine and…
roscioli
  • 1,200
  • 3
  • 15
  • 33
0
votes
1 answer

How do I git out of this mess with a git submodule?

I've got a git repo with Wordpress as a submodule. I was trying to update Wordpress and really screwed things up. I just want to get all of the code from the 3.7.1 tag in the remote repository, but this doesn't work; git fetch --tags git checkout…
Jo Sprague
  • 16,523
  • 10
  • 42
  • 62
0
votes
2 answers

Git prevent checkout for ignored directories

I work on a project in a team and I need to checkout branches of others from time to time. Here is the thing. All CSS and JS files are compiled from SASS/Coffeescript and it's all stored in /Static directory. Obviously the compiled files are not…
Michal Artazov
  • 4,368
  • 8
  • 25
  • 38
0
votes
2 answers

Understanding git fetches and your local repo

I read that, after doing a git fetch, your local repo has all the commits from the original repo, but that they are "not yet integrated into the cloned repository's local branches". What does this mean/imply? Do I then need to checkout my branch to…
user1768830
0
votes
1 answer

Just download content of remote branch , not the repository

Do we have anyway to just download content of a branch , and not the repository. I need a branch to do build on a server, So I am interested only in just my files not any repository stuff.
Ahmad
  • 2,110
  • 5
  • 26
  • 36
0
votes
4 answers

Can't checkout master branch

I've been working in a branch with some code to improve an application. Now that it's finished, I want to merge this branch with master branch, but I can't. I first tried to checkout to master branch like this: $ git checkout master but I get this…
Manolo
  • 24,020
  • 20
  • 85
  • 130
0
votes
1 answer

git checkout for xcode

So I've been watching some videos from the Facebook Mobile DevCon 2013 (http://www.youtube.com/watch?v=mLuaUtbGvEM) on youtube and every time someone explains something new he or she does a new checkout and all the new code was added to your…
Mark Molina
  • 5,057
  • 8
  • 41
  • 69
0
votes
3 answers

Git on the road - push error '[remote rejected] master -> master (branch is currently checked out)'

Let say I'm on the road with a friend, we are offline from the bare git repository. I have a working copy (with .git folder) and my friend want to help me out so he clone my git repository from my working copy and work on its own and of course both…
wily
  • 355
  • 1
  • 3
  • 9
0
votes
1 answer

Post-merge hook did not run on fetch origin, checkout remote branch

After doing a "git fetch origin" to pull in a remote branch added my a colleague, I did "git checkout . This output: Branch set up to track remote branch from origin. Switched to a new branch "" I have a post-merge script to run SQL scripts merged…
ericleit
  • 311
  • 3
  • 11
0
votes
1 answer

Getting current of current remote git repository

I am working on a python script that takes a repository name from a properties file and it either it does git remote add -f origin repository_name or if it finds a .git folder already there, it just fetches a branch. My problem is, the above…
Ahmad
  • 2,110
  • 5
  • 26
  • 36
0
votes
1 answer

Checked out an old revision in git, then returned to latest revision, but deleted files from old revision are still in local directory?

While using git, I checked out a specific revision in my master branch: checkout . I only did this to take a look at some previous files, I made no changes. I then attempted to reset my current state to my latest revision. …
user1167662
  • 1,245
  • 3
  • 16
  • 25
0
votes
1 answer

Moving gitignored files with branch after git-checkout

I have a single repo where each branch specifies different approaches to the same problem: $ git branch approach1 approach2 approach3 Now for each of these approaches, I have several auxiliary files, but the auxiliary files are specific to each…
0
votes
3 answers

How badly did I hose my git repo?

My project has a bare repo setup on the server. I'm currently on branch 0.9/develop. I merged 0.9/develop with a branch that another developer was working on. It turns out that it would be way more work to fix his code than to obliterate his changes…
Ben Harold
  • 6,242
  • 6
  • 47
  • 71
0
votes
1 answer

Can I checkout using git and delete all but one dir on my working tree?

I need that every time I checkout a revision, the working dir end with just the files and directories of that revision, not matter what existed in the working tree at the time I checkout, with exception of a directory on my working that I never want…
user1785721