428 questions
2
votes
1
answer
113
views
Stop git from relating related history on fetch
I'm working on creating a template system with git, but git is being too clever (for my use case) by automatically 'unshallowing'. Let me try to explain.
For context, the templating process starts by ...
0
votes
1
answer
92
views
Getting "fatal: bad revision" when trying to unsquash a commit in Git
Regarding How to unsquash a commit? I want to do the same - unsquash a commit.
For the moment I had the same idea to simply delete the current commit and cherry-pick the squashed commits of it.
...
0
votes
1
answer
92
views
How to fetch an unreachable commit from remote? [duplicate]
Some commits were lost on the remote main branch because of force pushing.
The ID of the lost commit was recovered by inspecting closed pull requests.
The commit page has a warning "This commit ...
2
votes
1
answer
106
views
How does `--reference-if-able` affect `git fetch` and `git push` propagation in a clone?
I have two local clones of the same remote repository (urlA):
mirror/ – created with
git clone --mirror urlA mirror
dirB/ – created with
git clone --reference-if-able ../mirror urlA dirB
In dirB, ...
3
votes
1
answer
116
views
What happened to git pull --all and how do I achieve the same effect?
Here's my directory structure:
root
|
\- GitRepoA
\- GitRepoB
\- GitRepoC
...
\- GitRepoN
I'm trying to effectively git pull master or git pull main in each of my git repos. Some of them use master, ...
1
vote
1
answer
232
views
performance of the checkout step in an Azure DevOps YAML pipeline
We have a couple YAML pipelines in Azure DevOps (cloud hosted). We've recently ported them from classic pipelines to YAML. The pipelines checkout code on a specified branch (main by default or the ...
0
votes
1
answer
91
views
Remove git data without breaking fetch
I'm processing a lot of Git repositories with software I wrote. The basic process is like this:
Do git clone --no-checkout --filter=blob:none <url>
Read interesting data from the repository and ...
2
votes
2
answers
63
views
A simple command to configure `git pull`
My remote repository has hundreds of branches, so fetch is configured conservatively:
% git config --get-all remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master
refs/heads/release/2.5:...
0
votes
1
answer
200
views
Your branch is ahead of 'origin/main' by X commits even after git push
I recently started using GitHub to manage my code, using git commit -a -m command to commit changes to all files (-a) added with git add <filename>, along with a message (-m).
After that, I run ...
0
votes
2
answers
147
views
Why does `git ls-remote --tags` require `git fetch --tags --prune` to work?
I’m working on optimizing my GitHub Actions pipeline.
One of the steps involves retrieving the latest tag from my Git repository.
Initially, I used the following commands to fetch the latest tag:
git ...
0
votes
1
answer
87
views
git fetch succeeds but git fetch --all gives a public key error
I have successfully cloned a repository from a GitLab instance. The repository is called main. (It was named that long before most people started using main as a branch name. That's probably not ...
0
votes
0
answers
27
views
Prevent "git archive" from talking to remote
I have a CI job which does a shallow checkout like this:
git clone --filter=blob:none --no-checkout $REPO .
git fetch origin $BRANCH
git checkout -f $COMMIT
I wanted to then archive that shallow copy ...
1
vote
0
answers
59
views
How do I restore commit history for a specific file that has been renamed?
I am trying to move some files from one repository (source repository) to a new one (target repository), and I want to restore all the previous commits of those files into the target repository to ...
0
votes
0
answers
40
views
How to get `git fetch` to pull only the remote branch corresponding to the current local branch? Don't want it to pull in any other remote branches
Given
$localBranch = git branch --show-current
$remote = git config branch.$localBranch.remote
$remoteBranch = git config branch.$localBranch.merge
$remoteTrackingBranch = $remote/$remoteBranch
when ...
0
votes
1
answer
80
views
Why does `git pull` pull 1000s of remote branches to my local?
When I do git pull it fetches all remote branches to my local. And it saves them as remote-tracking branches (this is not the issue, though). I think it also fetched tags and maybe other things too.
I ...
2
votes
1
answer
66
views
`git fetch origin foo` vs `git fetch origin foo:origin/foo`
I have 2 remote branches, foo and bar.
Neither foo nor bar exist locally. They appear in neither of the following
git branch # local branches
git branch -r # remote-tracking branches
I did git fetch ...
0
votes
1
answer
115
views
Why does `git pull origin master:master` from non-master branch cause branch to be rebased?
I'm on branch master and do git log
commit 9937b91089895fac45a39a3bda2935e19eb42554 (HEAD -> master, origin/master, origin/HEAD)
...
git status prints
On branch master
Your branch is up to date ...
0
votes
1
answer
693
views
Why do I have to run "git branch --set-upstream-to=origin/<branch> local-branch-name" while doing git pull?
I am wondering why I have to git branch --set-upstream-to=origin/<branch> local-branch-name when doing git pull? Is there a way to keep the upstream the same as the current local branch of ...
2
votes
0
answers
2k
views
Git pull error: fatal: expected 'acknowledgments'
We are using Github to host our repo and the authentication mechanism is through an app.
The git pull randomly fails with the following error. Emphasis on "randomly", it works 90% of the ...
0
votes
0
answers
171
views
When replying to sync, git fetch, or git clone, bad packet length xxxxx is reported
When I execute repo sync to pull a large project, I will report a Bad packet length xxxxx error, and sometimes I will also report this error when using git clone. How should I handle this?
Error info:
...
0
votes
3
answers
448
views
How to get the name of a git repository after fetching it and checking it out? [duplicate]
If I were to clone a repository, git automatically determines the name of the repository and clones it into that directory.
As per the git clone documentation:
<directory>
The name of a new ...
0
votes
1
answer
108
views
Fetch and set up remote tracking with a branch not listed in the git fetch config
I work in a very large monorepo, so by default the fetch configuration is constrained to avoid pulling down thousands of branches and slowing down git (i.e. fetch = +refs/heads/master:refs/remotes/...
0
votes
1
answer
75
views
ALTERNATE_DB_ENVIRONMENT environment variable does not work for setting alternate object directories in git
According to this comment in object-file.c in the source tree of git, setting the ALTERNATE_DB_ENVIRONMENT environment variable should work instead of using the .git/objects/info/alternates file.
The ...
0
votes
1
answer
2k
views
fatal: ambiguous argument 'main': unknown revision or path not in the working tree
I'm using NX in my CI with GitHub Actions and I checkout the repository using actions/checkout@v4.
When I try to use nx affected:..., for example nx affected:lint or nx affected:test it fails with the ...
0
votes
1
answer
52
views
How do I pull merged changes from a sub-branch back onto the original branch locally?
I created a branch. Let’s call it feat/feature1.0.
My friend created a branch off of this branch. Let’s call it feat/feature1.1.
My friend has committed and merged their changes into the original ...
1
vote
0
answers
95
views
Why does fast-forwarding with git fetch reject an ahead branch?
To fast-forward from origin I can do git merge --ff-only origin/BR if BR is checked out, otherwise git fetch . origin/BR:BR (or git fetch origin BR:BR to also update origin/BR).
Using git merge, if BR ...
2
votes
0
answers
66
views
How to git fetch and prune only a subset of exactly specified refs
I want to synchronize certain subset of custom refs from origin to the local copy:
git fetch --force --prune origin refs/x/1:refs/x/1 refs/x/3:refs/x/3
I need git fetch to delete local ref when the ...
0
votes
0
answers
23
views
Working with two git repos on same server but without a bare-repo
I've been working for a while with git and multiple remote repos, cloned form a bare-repo. So, I could commit changes on one repo, push to the bare and fetch/merge into the other repo.
On a new, small ...
1
vote
0
answers
105
views
Optimizing Git Cloning for Large Repository with On-Demand Access to Version History
I'm working with a large private Git repository with a single branch and I need to optimize the cloning process. My requirement is to later access the Git version history and the different versions of ...
0
votes
1
answer
347
views
Git Log After Git Fetch Upstream
I really wanted to understand how git behaves and what's happening underneath the plans after I run a git fetch upstream HEAD on a clean local repository.
Basically the steps were as follows:
Create ...
0
votes
1
answer
74
views
Difference Between HEAD and HEAD:HEAD
What is the difference between HEAD and HEAD:HEAD notation in git commands e.g.:
git fetch origin HEAD:HEAD
I can even understand what git fetch origin HEAD does, however, not using the other ...
2
votes
0
answers
145
views
Restore a remote branch after a `git fetch --prune`
I ran git fetch --prune and I see:
- [deleted] (none) -> origin/branch_name_here
I can not tell from the branch name if it was an important reference.
How do I find out where origin/...
1
vote
0
answers
52
views
What checks does git perform to "force update" in a fetch? Is it something I can actually *see*?
So let's assume I have the same repository in two different local directories, besides origin. Let's call these localA/master and localB/master. Both of them synchronized with an origin/master.
The ...
0
votes
1
answer
63
views
Fetch refs not associated with a branch
I have a program that runs some scientific tests. I have written a git post-receive hook for the server that runs these tests:
When it receives a commit, e.g. deadbeef..., run the program
Commit the ...
-1
votes
1
answer
96
views
How to solve conflicts while pulling a branch from a remote repository?
I am currently working on a project that involves forking a specific GitHub repository. In my forked version, I am required to incorporate a branch named windows into my project. The original main ...
0
votes
1
answer
890
views
Git cannot checkout remote branch despite `git ls-remote origin` showing it exists
I'm struggling to checkout a remote branch that I know exists, because it shows up with git ls-remote:
$ git ls-remote
242d56fbd8d8af67df3157bd047252f5580e3df8 HEAD
...
-1
votes
3
answers
2k
views
Why does actions/checkout fetch the latest commit right after cloning the repository?
While trying to make sense of the action actions/checkout@version, I came across this answer in which the following was stated to explain what happens when the same action is executed:
The default ...
1
vote
1
answer
86
views
How to merge large number of changes info common repo?
There are two developers working on branches dev1 and dev2, respectively, and usually every time one of them commits a change they do a PR into a common dev branch.
Both developers have made a bunch ...
-3
votes
1
answer
914
views
How do I set git fetch --force in git config?
I want every fetch and pull to get tags from origin, replacing local ones if they differ, and delete tags and origin/ branches that are not on origin, so I did this:
git config --global fetch.tags ...
0
votes
1
answer
728
views
git remove single line from file in git history
I accidentally committed a line of code that was not meant to be part of the commit.
class Engine {
x: X
protected _events: Event // <-- this line was accidentally included
y: Y
the ...
0
votes
0
answers
61
views
Git fetch on master breaks
I am trying to run below command after shallow clone.
//Run first - Passes
git fetch --depth 100 --update-head-ok origin master:remotes/origin/master
// Run next - Fails
git fetch --depth 100 --...
5
votes
1
answer
93
views
Did git configuration `branch.<name>.fetch` ever exist?
Git configuration branch.<name>.fetch is mentioned in the first git-fetch example1:
Update the remote-tracking branches:
$ git fetch origin
The above command copies all branches from the remote ...
2
votes
1
answer
382
views
`git submodule update` always keep fetching the same commit
I have a Git repo with one submodule and two commits that change the submodule's HEAD. If I check out one of the commits, and do a git submodule update, this succeeds without having to connect to a ...
0
votes
1
answer
338
views
Network failure during git fetch command
I'm trying to investigate what happens if the network would fail during a git fetch command.
I can't find any documentation that really goes into detail of the fetch command and digging into the git C ...
1
vote
3
answers
84
views
Why does this person (see link to article) use checkout to create a feature branch from the development branch and not fetch?
I thought you had to use fetch to get the latest version of a branch from the remote repository. If you do this as the person who wrote the article, don't you create a new feature branch from the &...
0
votes
2
answers
226
views
How do I make `origin/HEAD` work with partial fetch settings?
In a typical "regular" git clone, one ends up with .git/config as follows:
[remote "origin"]
url = [email protected]:orgname/reponame.git
fetch = +refs/heads/*:refs/remotes/...
1
vote
0
answers
198
views
How can I grab specific SHA-1 hashes from remote repositories?
This script iterates multiple Git repositories in order to get their latest commit SHA-1 per branch.
These commands are launched inside an arbitrary .git directory, so Git commands can be invoked ...
0
votes
0
answers
43
views
git fetch overwrote the current main with an old push to another remote, how to get my main back to how it is on github?
I wanted to get the tags that another contributor added to a github remote, so I ran git fetch --all --tags. The resulting fetch looked like this:
$ git fetch --all --tags
Fetching origin
remote: ...
1
vote
1
answer
457
views
Can I set in Jenkins to not fetch every file from gitHUB?
I have a project on gitHUB where I have two '.txt' file at .project level. I would use them for comparison a previus run to a new run to find out the difference.
I use Jenkins to build the project, ...
0
votes
2
answers
3k
views
Git pull shows "already up to date" but they're wrong
DISCLAIMER : There's already a post that already addresses this issue but sadly the author did not find any definite answer.
Here's my issue : git pull shows "already-up-to-date" but they're ...