close
Skip to main content

New answers tagged

Score of 0

Change admin password in Gitea

If your Gitea runs in a container based on docker compose cd /path/to/docker-compose-file docker compose exec -it --user root <gitea-container-name> su git bash -c "gitea admin user change-...
Score of 3

Change git clone behavior to use redirects as origin

No. Following the redirect and changing the configured remote are two separate things. git clone records the URL you gave it as the URL for origin. An HTTP redirect may change where Git makes the ...
Score of 0

git pull displays "fatal: Couldn't find remote ref refs/heads/xxxx" and hangs up

Refresh it: git remote remove upstream git remote add upstream <url> 🎩-tip: johnwslongland
Score of 1

Given a multi-commit PR, how to go from a file in "Files changed" to the commit(s) where that file was changed?

1 parent f09500b commit b87bdb9 So... the commit you are dealing with is, from git's POV, a straight non-merge commit... what is also known as a "squash merge", given that it's a commit ...
Score of 0

How to keep "git pull" from deleting local files

I am late with the answer but I had the same issue on Windows when running git pull: Deletion of directory '...' failed. Should I try again? (y/n) In my case, the pull was blocked because Git could ...
Score of 0

An app includes some files from another app, how to do this in git?

Make a superproject including each as submodules, with three branches for releases of each app recording the corresponding version of the other two apps needed to build that release. Then clone --...
Score of 1

What tool should I use to split git commit into multiple ones?

If you use Git 2.54 or above, you can use the new(ish) history split command: https://git-scm.com/docs/git-history#Documentation/git-history.txt-splitcommit--pathspec Use it as follows: $ git log --...
Score of 2

An app includes some files from another app, how to do this in git?

git clone will never create files outside of the newly cloned repository's working-tree directory. If your app A currently expects to reach outside via ../appB/, then you have these choices: Make app ...
Score of 0

What would I use git-worktree for?

Is there anything about git-worktree that couldn't be done beforehand and that justifies this whole new, complex feature? There are a lot of answers motivating why you'd use worktrees, but generally ...
Score of 1

Multiple git hooks for the same trigger

Since version 2.54, released in February 2026, git supports multiple listeners per hook. Create a hook Associate hook name to a shell command: git config set hook.<hook-name>.command <shell-...
Score of 0
Accepted

LFTP in gitlab CI: files are not updated on FTP server even if they are changed in the last commit

The bug: the --ignore-time option made files be compared by byte size alone, so any edit that didn't change the file's size — moving a block, swapping one digit for another — was seen as "nothing ...
Score of 1

Switched branch without commiting changes, 'error: Could not write index. FullHarvest_Daph (MajorPush-1)/Packages/manifest.json: needs merge'

I just had the same error message with git 2.47.3 when a file needed a merge and git stash was unable to perform. The error message "could not write index" makes a more important impression ...
Score of 0
Accepted

Git clone over SSH hangs in WSL2 at expecting SSH2_MSG_KEX_ECDH_REPLY

It stalls at SSH2_MSG_KEX_ECDH_REPLY because that is the first large inbound packet, carrying the host key and signature. PowerShell works because the Windows stack has black hole detection. HTTPS ...
Score of 0

Sparse checkout but exclude or ignore files in root?

It's possible to use the --no-cone option with git sparse-checkout set to only checkout the wanted path, meanwhile excluding all other files in a sparse checkout: # 1. create the initial sparse clone ...
Score of 1

git ignore everything with "secret" in path or filename

You can use this: *secret* It will exclude any file or directory (with its content) whose name contains secret.
Score of 1

git ignore everything with "secret" in path or filename

Just add both entries as: **/*secret* **/*secret*/**
Score of 0

Playwright Git Local vs. Remote Version

There are two approaches you can take here: two completely separate files, or use an environment variable to change your configuration values. Two Config Files For this, you'd set up the two ...
Score of 0

How can I calculate the number of lines changed since last commit in Git?

If you want a machine-friendly, easily parseable diff per file (which per your description of your script, it appears you may), the --numstat option should work well. git diff --numstat Output: 0 ...
Score of 1

How can I calculate the number of lines changed since last commit in Git?

The --shortstat option of the diff command will give you the total number of lines changed across all files. git diff --shortstat Output: 2 files changed, 84 insertions(+), 117 deletions(-) ...
Score of 0
Accepted

How to `git push` to a repository with different owner on a multi-user system without executing any code from destination?

Researching this question: there is no direct way to prevent git executing any code from the remote, nor is there any exhaustive list of git facilities (hooks, configuration variables, etc.) that ...
Score of 1

Git - how do I view the change history of a method/function?

In my case, I wanted to trace the evolution of a protobuf message (~a struct), so only a regexp helped: it carves out a portion of the diff starting with message StructName { ending with } within a ...
Score of 0

How can I check out a GitHub pull request with Git?

You can make checking out PRs convenient with Git aliases: git config --global alias.pr \ '!f() { git fetch origin +pull/$1/head:pr-$1 && git switch pr-$1; }; f' git config --global alias....
Score of 0

Bun install fails for private Git repo even with .npmrc and env variable for Bitbucket token

Bun only supports this now via the git+https synax, and by appending a dot in the end of the hostname "@passportscan/sdk": "git+https://bitbucket.org./repo-cloud/repo-sdk.git#main" ...
Score of 3

GNU repo contains apparent ghost import

As phd's answer correctly states, funcs.h is generated during the build process. Typically, if you build a software package from a source tarball, the build sequence is something very similar to this: ...
Score of 0

Why should I use core.autocrlf=true in Git?

Modern Solution (2026): Use .gitattributes instead of core.autocrlf Relying on core.autocrlf (true or false) is error-prone because it requires every developer on a team to configure their local Git ...
Score of 6
Accepted

GNU repo contains apparent ghost import

This is how the file is generated in different Makefiles: Makefile.aut: funcs.h: ${SRC:%=${srcdir}/%} -mv -f ${srcdir}/funcs.h ${srcdir}/funcs.h.old grep -h '^public [^;]*$$' ${SRC:%=${srcdir}/...
Score of 0

Git keeps prompting me for a password

Maybe, GCM (Git Credential Manager) is frustrating you, as it surely did to me! GCM has a feature called gitHubAccountFiltering and tries to strictly filter and match which GitHub account or token ...
Score of 0

Zip latest committed changes only

I've always used this: git archive --format=zip HEAD `git diff HEAD^ HEAD --diff-filter=ACMRT --name-only` > changes.zip
Score of -1

How to `git push` to a repository with different owner on a multi-user system without executing any code from destination?

This is not at all what you think it is. This vulnerability affects users working on multi-user machines where a malicious actor could create a .git directory in a shared location above a victim’s ...
Score of 1

Git - creating a pretty log using rebase

2026: There is still no rebase option that makes rewriting a branch shared by several developers safe. However, newer Git versions provide much better ways to separate: the real collaborative history ...
Score of 5
Accepted

Using git, how can I checkout a commit containing files that have invalid file names?

e.g., "assets/images/[email protected]:Zone.Identifier" These specific names are valid in Windows, indeed they come from Windows. NTFS uses a : to separate file name from stream name – most files ...
Score of 0

Case Insensitive Search on Git log comments

Because the search pattern is a regular expression, you can do something like this: /[Ff]oo This will match either Foo or foo. It's a bit tedious if you want to also match fOo, foO, fOO, etc., but ...
Score of -1

How to `git push` to a repository with different owner on a multi-user system without executing any code from destination?

EDIT: In order to ensure this: answers the question directly, and doesn't wander around in unrelated areas I have intentionally included quotes, unfortunately, some readers may feel that the quotes ...
Score of 0

Installing Git on OS X

On macOS with Homebrew-installed docbook toolchains, the following works quite well: XML_CATALOG_FILES="/usr/local/etc/xml/catalog" make -C Documentation -j This is obliquely described in a ...
Score of -1

How do I include --no-pager in a Git alias?

The problem is where --no-pager has to go. It's a global Git option, not a log option — it only works if it appears before the subcommand, like: git --no-pager log ... But a normal Git alias (hist = ...
Score of -1

GitLab CI/CD job doesn't find "main" git branch

So, following @jonrsharpe links: from https://stackoverflow.com/a/74627772/15304, I see that I should use git branch -a to have a reliable list of what branches are known, from https://docs.gitlab....
Score of -1

Stash Git error "fatal: remote error: CAPTCHA required"

I recently had this error and removing the credentials did not help. Ecosia search engine's KI came with the below solution which worked fine: # git submodule deinit -f <submodule-name> git ...
Score of 0

What's the proper way to "go get" a private repository?

ssh key solution (this does not cover API key solution) As of 2026, go 1.26.x and above, following will cover both git and go command line for using private repository service/server with ssh key. If ...
Score of 1

Cannot clone git from Azure DevOps using PAT

You can set your GCM authentication to use oauth. GCM uses PAT by default. PAT is now being deprecated. Also there is an ongoing effort to remove SSH enabled AuthN. Use oauth for your Azure DevOps, ...
Score of 0

Git through Visual Studio Code is unusably slow

I had to set "git.autofetch" to false in settings.json. It looks like autofetch runs in the background and fetches from the remote on a timer. VSCode's Git extension queues git operations ...
Score of 2

Break a previous commit into multiple commits

In Git 2.54 (April 2026), there is a new experimental git history split <commit> command. Reference: https://cekrem.github.io/posts/git-history-git-2-54/
Score of 0

git subtree pull says that the working tree has modifications, but git status says it doesn't. What gives?

Even just empty folders in the project could lead to this problem. In my case removing them helped.
Score of 0
Accepted

Can I limit ClickOnce deployment through VS by Git branch?

Get current git branch name git rev-parse --abbrev-ref HEAD rev-parse: Pick out and massage parameters --abbrev-ref: show object short names instead of hash HEAD: names the commit on which you based ...
Score of 0

Setting up and using Meld as your Git difftool and mergetool

The only thing you do is: git config --global merge.tool meld Git will set up the rest, including the difftool. You can see in the Git source code that it knows how to set up a selection of merge ...
Score of 1

Commit to git with a different path?

It should be possible using these git options: --work-tree=/somedir: specifies the root of your work tree --git-dir=/somedir : specifies where your .git dir is -C /somedir : runs git as if in another ...
Score of 0

How to commit and push file from different directory to the same repository in github

git add --work-tree=/the/other/directory file1 file2 Will add file1 and file2 from another directory as if they were in the current directory.
Score of 0

Creating a Git submodule that refers to a particular commit in other repository

Online instructions say you can "git checkout <commit>" within the submodule directory but commands like git commit and git log don't seem to recognize they're in a submodule though it ...
Score of -1

Automatically show status after git add

I know it has been a while since this was asked. But I wanted to answer this here because I believe it fully matches OP's question: Call git add (the original API to add to index) and it automatically ...
Score of 3

Use git to list differences with their respective line blame information

I created this script, let me know if it's what you need. For context: just diff and a straight blame is not good enough. Deleted lines specially require some work. It might be tempting to think that ...

Top 50 recent answers are included