Questions tagged [git-checkout]
Checkout a branch or file to the current working tree in a Git repo.
1,030
questions
0
votes
1
answer
13
views
How to make git always warn to stash or commit changes before checking out a different branch?
When I have modified my current branch and check out to a different branch, git warns me that I have not stashed or commited fails only when there is a conflict between the two branches.
How can I ...
0
votes
1
answer
22
views
How to switch to another branch while recursively initing submodules
I have a git repository with several submodules (see an example). Its structure looks like this:
I--A--B <- main
\
C <- branch-c
Commit A adds a submodule-a
Commit B adds a ...
1
vote
2
answers
49
views
Git: How to move origin/master from an abandoned branch to current HEAD?
Git newbie here. I made some changes that I wanted to abandon. So I did a checkout to an earlier point, and started working again. I don't recall exactly what else I did, but here is my current ...
0
votes
2
answers
23
views
Delete again a file via a previous commit that deleted that file in the first place
Scenario:
delete file.txt file, commitA and push
restore file.txt via git checkout commitA~1 file.txt , commitB and push
I want to delete the file again by invoking commitA by running the following ...
0
votes
0
answers
15
views
JGit checkout error while trying to examine repository with repodriller
I'm trying to run repodriller on all the commits of Jsoup. Each time I start the analysis of a new commit, I need to checkout the repository for that commit, so in my CommitVisitor, I execute this ...
1
vote
1
answer
24
views
Git - Loosing file after renaming and branch, why?
I initialize a new repository in an empty folder:
git init
Now I copy two files A.java and B.java into this folder and commit:
git add A.java B.java && git commit -m "Added A.java and B....
0
votes
0
answers
14
views
What is the meaning of "^" in Git checkout? [duplicate]
Hi i used the command git checkout to retrieve a file from an old commit.
Example:
git checkout <hash>^ -- <filename>
My question is simple.What is the meaning of the ^ after the hash?
...
1
vote
1
answer
39
views
Git : explore folders tructure of old commit without checking it out
I want to look at the folder structure of an old commit that I cannot checkout anymore (it had some Git LFS stuff which is now broken beyond my power to repair it).
I can already diff it to its parent ...
1
vote
0
answers
67
views
jenkins SCM checkout poll issue with multiple repo
I have a Jenkins job where I'm checking out 2 repos,
The first repo "dev" contains src code and the Jenkinsfile and this repo is configured in Jenkins UI along with PollScm enabled. The ...
1
vote
1
answer
23
views
Copying content of a directory on another branch
I have 2 branches on github:
master
gh-pages
My branch master has the directory _site which contains all the files that I need to be stored on the root of gh-pages.
I am using the git command:
git ...
1
vote
1
answer
35
views
Any way to avoid git checkout -f "warning directory is not empty"?
I have a git repository that contains multiple branch that diverged a lot. When I say diverged it means that each branch can contain new folder or submodule and a lot of diffs between files.
When you ...
1
vote
2
answers
116
views
Why Github repo has no "clone" option?
Well, probably so dumb question but I am not sure even how to search for it, I am pretty new to github. What I do is just watching some tutorials and I want to download the code from the link shared ...
0
votes
1
answer
29
views
Git: If I've been working in detached head state for multiple commits, will I lose anything by getting out of it?
A while ago I checked out a previous commit, then checked out my most recent commit again. I didn't realize this at the time, but that left me in a detached head state. I've done multiple commits ...
1
vote
1
answer
65
views
Git submodule ignore error at branch checkout when that submodule does not have that branch
I have 6 sub modules in a git repository, says submodule1, submodule2,... submodule6.
On 4 sub modules: submodule1/2/4/5 I have a branch, says featureABC, on them.
When I run the checkout command:
$ ...
0
votes
1
answer
51
views
Checkout files from a specific commit failed with space in the path
What I want to achieve is to get all updates of a specific commit 76363636 from branch1 to branch2.
I used following codes instead of just checkout this commit, as it does not fit my purpose :
git ...
-1
votes
1
answer
33
views
Git: checkout out most recent commit vs checkout out name of branch? [duplicate]
I just did a git commit, then did git checkout <previous commit>, then did git checkout <most recent commit>. It then said I was in a detached HEAD state. I think I read somewhere that ...
0
votes
1
answer
30
views
Restore a folder that's deleted in the local branch
I'm trying to restore a folder I deleted in a local branch but I am having trouble doing it. I have created a new branch from main and deleted one of the folders, while I worked on the branch and did ...
2
votes
2
answers
79
views
Switch between git branches [duplicate]
I have a repository having two branches master ( keeps final error free code ) and develop ( developing branch ).The default branch is master, I cloned and worked on the project, but unfortunately I ...
0
votes
2
answers
54
views
Checkout several branches from Git
I want to clone some Git repository on local machine, and create 3 folders:
master - for master branch of the project
tag777 - for the specific tag of the project
commit888 - for the specific ...
0
votes
1
answer
51
views
Delete files/directories matching a pattern buried in possibly several commits in a repo
Please see this question, and my comment at the bottom of the question.
I have just cloned a repo in a Windows 10 OS which I developed in Linux, and git won't let me check to a branch because elements ...
-1
votes
1
answer
54
views
Checked out previous git commit, now can't switch back to HEAD
In my React Native project I checked out a previous git commit using git checkout <previous commit SHA>, then tried to return to HEAD using git checkout <most recent commit SHA>. It said ...
0
votes
1
answer
183
views
Why does this "complicated" git clone/checkout cause gitversion to fail?
I have the following pipeline syntax code in a Jenkinsfile to clone a git repo:
checkout([$class: 'GitSCM',
branches: [[name: "${branch}"]],
...
0
votes
1
answer
25
views
Git removing references from invalidly, non-existing, c:\tmp\file.har named file in bitbucket
This question is in regards how to in Git removing references from invalidly, non-existing, c:\tmp\file.har named file in bitbucket
I usually work on linux (where the error do not surface, probably ...
1
vote
2
answers
63
views
Prevent git from creating branches that use names of remotes?
I often accidentally checkout remote tracking branches incorrectly:
git checkout -b origin/fixbugs
The -b should be a -t.
This mistake creates a branch called "origin/fixbugs". How could I ...
1
vote
2
answers
791
views
Why is clone succeeded, but checkout failed?
Getting following error/warning when I clone a large project in my Windows 10.
....
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_common.h: No such file or directory
...
1
vote
1
answer
59
views
git checkout <branch> <file path> does not match what is on <branch>
I am having a confusing issue with git
On main/development I have a file that has the most up-to-date changes of UsersTable.tsx
On my working branch chore/add-linting I am a few commits ahead, but I ...
1
vote
1
answer
52
views
Why is a new branch in our github repo unavailable for checkout?
A colleague created a new branch in our repo in Github, but I cannot seem to use checkout to get it, and when I do a git branch -a (using Git Bash, Windows 10) it is not listed among the branches. ...
1
vote
2
answers
79
views
Clone another branch after cloning single-branch
I'm using the below command to clone one branch:
git clone user@git-server:project_name.git -b branch_name --single-branch /your/folder
Now I want to check out another branch from the server. I tried ...
2
votes
1
answer
82
views
Git setting submodule.recurse is not working (Git Bash)
I'm using Git Bash for Windows, version 2.34.1.windows.1. I would like Git to automatically initialize submodules when I do a clone, checkout or pull. I found this question, but the accepted answer, ...
0
votes
1
answer
288
views
Checking out from master and used -f with uncommitted changes
I am working for a company and we have a download counter on our website that is updated daily, so every time I pull from the remote repository there are changes that need to be committed, but I've ...
1
vote
1
answer
33
views
How to add add existing directory to version control in existing repo without modifying files?
I have to put a pretty big project under version control, which has two versions (dev and prod). These two were kept in "mostly sync" by copying files manually over the years, but - ...
0
votes
0
answers
24
views
Git checkout again only files initially checked out from another branch
I need 20 branches, each branched from a single main feature branch. These branches will be used to generate pull requests (BitBucket) repeatedly as work progresses. So every now and again, I want to ...
0
votes
2
answers
34
views
How do I save the current HEAD so I can check it back out in the same way later?
I want to do:
current_state="$(git something-or-another)"
and then, later:
git checkout "$current_state"
and get back to whatever situation I had originally, whether it was a ...
0
votes
1
answer
37
views
git checkout master isn't reverting my working directory, it's still showing changes from the branch
I have my git master branch, then i created a new branch to work on a new, long-term feature, and i've added and committed changes to this new branch, and pushed them to github. I then pulled these ...
1
vote
1
answer
133
views
Git checkout to master from another branch updates automatically local changes?
I have an empty git repo in which first I create a hello.txt file with content "pulkitsharma".
After this I added it to staging and then commited the changes in master branch. Then I create
...
-1
votes
1
answer
37
views
Can I revert to a previous version of just one file even if I git added all files before a commit?
Can I revert to a previous version of just one file even if I git added all files before a commit?
So, this is what I did:
git add . then git commit -m "my changes" then git push
So there ...
2
votes
1
answer
629
views
How to `Disable or modify the sparsity rules`?
kes@work ~/t/etc $ git rm local.conf
The following pathspecs didn't match any eligible path, but they do match index
entries outside the current sparse checkout:
local.conf
hint: Disable or modify ...
1
vote
1
answer
91
views
Git create new orphan branch on remote without pulling any branch
I'd like to create a new branch apple on a remote. This works:
git clone https://example.com/.git repo --depth 1 && cd repo
git checkout --orphan apple
git push origin apple:apple
The problem ...
-1
votes
2
answers
394
views
Unable to do "git checkout main" [duplicate]
Whenever I am trying to run:
git checkout main
I am getting an error:
error: The following untracked working tree files would be overwritten by checkout:
README.md
Please move or remove them ...
-1
votes
1
answer
176
views
What does the command `git checkout . path/to/file.php` do?
I have several modified files, my git status looks like
$ git status
On branch loyalty-module
Your branch is up-to-date with 'origin/loyalty-module'.
Changes not staged for commit:
(use "git ...
0
votes
0
answers
478
views
Jenkinsfile: how can I checkout branch instead of refs/heads/branch?
The following Jenkinsfile:
pipeline {
agent any
stages {
stage( "1" ) {
steps {
script {
def br = "demo_branch"
def clone_url = "ssh:...
0
votes
1
answer
69
views
Git checkout commit command works like git reset commit
I want just to see my previous commits without doing any changes.
I use:
git checkout id_of_certain_commit
But when I try to get back, it looks like everything that was from that point is removed. I ...
1
vote
1
answer
44
views
New branch from origin removed my unpushed commits
I'm currently a bit in trouble.
I was having 3 commits on my master that I didn't push to origin/master yet, they were just lingering.
Now I needed a new branch from my origin/master.
I checked out ...
0
votes
0
answers
206
views
How to use "git checkout -d"? [duplicate]
I meant to git branch -d reduce-4 to delete a local repo branch. I accidentally entered git checkout -d reduce-4 and it said (HEAD detached at refs/heads/reduce-4).
I used git checkout -d main to ...
0
votes
1
answer
203
views
Git Submodule is Not Updating to Correct Commit
I have a parent repository that has a submodule within it. If I look on the remote side, I can see that the commit ID pointed to by the submodule is 862e0c4e. This was recently updated to point to ...
0
votes
0
answers
70
views
payment using apple pay token with checkout in iOS
I have successfully generated the token with checkout.
checkoutAPIClient.createApplePayToken(paymentData: payment.token.paymentData) { applePayToken in
print(applePayToken)
...
1
vote
1
answer
22
views
Get untruncated list of files that would be overwritten by checkout
Suppose I want to check out branch X, and git says that many, many, many, VERY MANY files would be overwritten by checkout. So many in fact, that the list it writes out is truncated because it doesn't ...
0
votes
3
answers
171
views
Git auto undo changes when checkout or pull
For our projects we are using software TwinCAT which is based on Visual Studio (this means it is managed using VS project files) and we got this problem:
By just opening project there are created ...
0
votes
0
answers
153
views
Azure Pipelines Error: pathspec 'refs/remotes/origin/master' did not match any file(s) known to git
I am trying to checkout code from AWS Codecommit in an Azure Pipeline job. However, the dynamic build agent is complaining that it cannot find master branch.
I am restricted to only classic editor as ...
0
votes
1
answer
23
views
After doing `git pull` in a local repository, is it possible to find out which commit was the last before the git pull? [duplicate]
I did a git pull. Then, a fast forward merge happened and multiple objects and commits were added to my local repository.
Some things went wrong and I would like to go back to how the local repository ...