Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts tagged version-control
GitHub seems to require that one of the branches on it be marked as the "primary" branch. I understand this (perhaps mistakenly) to be the origin/HEAD. Why would they make it compulsory? On forked...
Can I programmatically get the name of the remote branch which my local branch is tracking? I'm interested in scripting around git-range-diff(1), so that I could do something like this: [alias] ...
I'm working with GitLab CI. The pipelines I'm designing contain several jobs that, once executed successfully, there shouldn't be any reason to retry/rerun them. This is an example: default: # ...
Is there a command I can run to get the path of global gitconfig for a user? Like git config --global --edit, but I want the path, not an editor window. I want the right path whether or not this f...
I did git fetch to quickly get latest commits. I did this instead of git pull so I could deal with merge conflicts offline. But my repository is still stuck on the old commit, and now git pull fail...
When I make a separate commit for code cleanup / style changes, I can suppress that commit from git blame so that I can follow a file's history easily without getting distracted by pure style chang...
The documentation for git stash list says list [<log-options>] List the stash entries that you currently have. Each stash entry is listed with its name (e.g. stash@{0} is the latest entry...
I have a git history that basically looks like this: * commit: XXX (HEAD -> main) | | * commit: YYY | | * commit: ZZZ (origin/main) | | ... Now I would like to turn everything after...
After switching to a different branch, git checkout - can move me back to the branch I came from. This is handy for times when I wonder "wait, what was that last branch again?" But this does not w...
I heard git pull is dangerous. Is it really dangerous? If so, why or how is it dangerous? Are there any flags that mitigate or remove the danger? What are the alternatives if it...
Suppose you have a largish git repository with many files of different types (both text and images) distributed among a number of nested directories. Parallel development has occurred on two branc...
What are the differences between git apply and git am commands? Both seem to be used for applying patches to repositories. When should one be used over the other?
Recently I had to push a new Docker image to our GitLab registry. I have the Maintainer role on that project. I had created a new token and used it to log in to Docker. However, when trying ...
How can we use git-send-email(1) to sign patches (emails) with the gpg(1) keyring? I've heard it can be done, but couldn't find anything in the git-send-email(1) documentation nor in a web search.
I have a project I normally build with nix and cabal, however I also want to publish my documentation onto gitlab pages. It's impractical to run my nix on the gitlab CI, so I've just been using cab...
Sometimes there are empty files named .gitkeep sprinkled around a repository. What are these files?
How to delete a branch from a remote in git? E.g. maybe you had this branch locally too, but you deleted it already according to this question. Now you want to get rid of the corresponding remote ...
I wish to add a property with the date of the current Git commit to the assembly info. From my .csproj: <Exec Command="git -C "$(ProjectDir)." log -1 --pretty=format:%ad" ...
I read posts (e.g., 1, 2, 3) that recommend triggering a CI build process by pushing an empty git commit. I don't understand how this is a good idea as the commit history will be peppered with mea...
GitHub has a setting wherein they offer to "anonymize" your user email from, say, somebody@example.com to somebody@users.noreply.github.com. I presume this is to prevent you from getting spam from ...
My actual motivation is to understand the semantics of the .gitignore file syntax in precise detail, for a program which is expected to emulate them as accurately as possible. However, while coming...
By default Gitlab CI jobs run on any commit. I would like to restrict some of them to run only on commits to specific branches. How to do this in .gitlab-ci.yml?
How to move the main branch back to an earlier commit in git?
Found an article about starting a repo with an empty commit. Read the post a couple of times, but still don't understand the reasoning: 1. git log and other commands blow up with terrifying ...
In git you can put your current changes aside for a moment with git stash. This is really neat but what often ends up happening is that you forget what was in there, and what was the state of the b...
Say I've made a bunch of changes to a file and would like to split those changes into two or more commits. Normal git add however stages the whole file in one go. So how to add only some of the ch...
How to delete a local git branch which hasn't been pushed to anywhere, and only exists locally?
I have a few different projects that rely on open source technology that I wish to make modifications to (say, to add key features for business or personal use) that will vary between upstreamable ...
I often find it useful to arrange things so that each commit on master's first-parent is a discrete change. It allows git log --first-parent --oneline to be used as a concise, automatically-generat...
I use git submodule foreach git pull to update my submodules. There's quite a few and it appears that foreach is updating them one by one, instead of in parallel. How can I do it in parallel?
I have created a directory named Temporary_add_to_version_control on Desktop. Now I am trying to reach that directory by typing the following in git-bash: cd ~/Desktop/Temporary_add_to_version_con...
I have created a tag in my project, using git tag v2023 However, I forgot to commit a few changes. Now I would like to move this tag to the current point (after having committed the changes I had...
How do I clone the repository with only part of the history? For example, let's say I want to download only the last 5 commits out of thousands.
I have git repo where the .git is deleted. I didn't realize it until after I made some changes to the code. I want to re-create the .git by cloning. However I don't want it to touch the files that...
On a live boot of Ubuntu 20.04, I was trying to clone into a private GitHub repository. I went through the hassle of installing git, and then gh, and making sure I was signed in through the termina...
Why does git merge take the source branch rather than the destination branch as a parameter? The most common merge case by far for me is "Okay, this branch looks good, let's merge it into branch X...
I have a git repository with some submodules. When the submodule repos get new commits on the remote, how can I pull them all?
Context I have started working on an Angular upgrade for a medium-sized project (from v. 10 to v. 15) and this is a rather long activity that is interrupted by other changes that need to be perfor...
How to make Husky run git hook? I have a working git hook, prepare-commit-message, but the moment Husky was installed, the hook stopped working. Not finding much luck, I then tried to make it a "H...
In Git documentation, there are lots of references to the term "HEAD". But what exactly is it? Some places refer to it as "a pointer to the current branch". So it's a branch? What is it used for?
On branch-x, I do git merge branch-y Now there are some conflicts, and git status shows Changes to be committed: new file: a new file: b Unmerged paths: (use "git a...
MWE In the terminal run: mkdir mwe cd mwe mkdir dir touch f1.txt f2.pdf dir/f1.txt dir/f2.pdf git init . Create a .gitignore with: * # ignore all !dir/ # except this directory ...
For some reason, I just wanted to undo a commit on my git repository, which I've done with the following command: git reset --soft HEAD~1 So far, so good. However, by mistake I issued the comma...
I have console scripts in my virtual environment in \env\Scripts, installed with packages (e.g. black, pytest, coverage). If I try to execute these in Git Bash, the output is not returned to the te...
I try to ignore paths in the Codeql code scanning file. But every scan it seems that scanning doesn't ignore these files, do you have any tips?
In git I branched feature-A from master. To reduce eventual merge conflicts later, I branched feature-B, which heavily overlaps and depends on A, from feature-A. A build of the feature-B branch s...
I'm using git for LaTeX projects and am in a little dilemma about how to best ignore files. if I add *.pdf to my .gitignore file, I keep forgetting to force add included graphics if I don...
I personally use git for deploying my hobby projects into cloud like Heroku. I came across the concept of sftp for uploading files. Now please differentiate these two deployments like when to use w...
I'm rather new to using git, so I'm not sure about the best practices regarding it. I have a feature branch branched off, and periodically when the feature needs to be updated I will add some commi...
For some tasks, I find git show-branch easier to follow than git log. For example, inspecting the history on someone's PR before merging it. git show-branch master topic stops at the first common ...