https://software.codidact.com/categories/38/tags/3349.rssNew Posts Tagged 'git' - Software DevelopmentSoftware Development - Codidact2024-02-26T17:18:21Zhttps://software.codidact.com/posts/290948How to delete a remote branch in git?Iizukihttps://software.codidact.com/users/649262024-02-26T13:59:07Z2024-02-26T17:18:21Z<p>How to delete a branch from a remote in git?</p>
<p>E.g. maybe you had this branch locally too, but you deleted it already according to <a href="https://software.codidact.com/posts/289829">this...https://software.codidact.com/posts/290818Git command formatting characters in msbuild are interpreted incorrectlyLyndonGingerichhttps://software.codidact.com/users/637672024-02-15T19:23:47Z2024-02-16T17:24:08Z<p>I wish to add a property with the date of the current Git commit to the assembly info.</p>
<p>From my .csproj:</p>
<pre><code class="language-xml"><Exec Command="git -C &quot;$(ProjectD...https://software.codidact.com/posts/290584Git apply vs git amIizukihttps://software.codidact.com/users/649262024-01-17T07:51:53Z2024-02-02T17:28:00Z<p>What are the differences between <a href="https://git-scm.com/docs/git-apply"><code>git apply</code></a> and <a href="https://git-scm.com/docs/git-am"><code>git am</code></a> commands? Both seem...https://software.codidact.com/posts/290180What is the point of triggering CI/CD with an empty git commit?torarittehttps://software.codidact.com/users/658732023-11-08T13:24:18Z2023-12-02T20:09:47Z<p>I read posts (e.g., <a href="https://developerinsider.co/how-to-create-empty-commits-to-test-ci-cd-or-anything-else/">1</a>, <a href="https://punitd.dev/tips/2020-06-06-empty-git-commits-for-CI/...https://software.codidact.com/posts/290317Can GitHub rewrite authorship of commits?Michaelhttps://software.codidact.com/users/659612023-11-29T21:14:26Z2023-11-30T18:43:33Z<p>GitHub has a setting wherein they offer to "anonymize" your user email from, say, <a href="mailto:somebody@example.com">somebody@example.com</a> to <a href="mailto:somebody@users.noreply.github....https://software.codidact.com/posts/290259Git-ignoring files with special characters in their names, especially newlinesKarl Knechtelhttps://software.codidact.com/users/646562023-11-21T08:04:09Z2023-11-21T13:00:50Z<p>My actual motivation is to <strong>understand the semantics of the .gitignore file syntax in precise detail</strong>, for a program which is expected to emulate them as accurately as possible. H...https://software.codidact.com/posts/290239How to run Gitlab CI jobs only in specific branches?Iizukihttps://software.codidact.com/users/649262023-11-16T11:27:24Z2023-11-16T11:40:41Z<p>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 <code>.gitlab-ci.yml</code>?</p>
<!-- g: js, md...https://software.codidact.com/posts/289927How to revert main branch to an earlier commit in git?Iizukihttps://software.codidact.com/users/649262023-10-09T12:39:44Z2023-11-14T00:58:55Z<p>How to move the <code>main</code> branch back to an earlier commit in git?</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/290182What are the benefits of starting a Git repo with an empty commit?torarittehttps://software.codidact.com/users/658732023-11-08T14:13:08Z2023-11-08T17:06:25Z<p>Found an article about <a href="https://web.archive.org/web/20170919074934/http://bit-booster.com:80/doing-git-wrong/2017/01/02/git-init-empty/">starting a repo with an empty commit</a>. Read th...https://software.codidact.com/posts/290176How to compare a git stash to the current working tree?Iizukihttps://software.codidact.com/users/649262023-11-07T07:59:01Z2023-11-07T10:16:32Z<p>In git you can put your current changes aside for a moment with <code>git stash</code>. This is really neat but what often ends up happening is that you forget what was in there, and what was th...https://software.codidact.com/posts/290031Git add/stage only part of a file's changesIizukihttps://software.codidact.com/users/649262023-10-17T10:07:32Z2023-10-17T10:28:56Z<p>Say I've made a bunch of changes to a file and would like to split those changes into two or more commits. Normal <code>git add</code> however stages the whole file in one go.</p>
<p>So how to ...https://software.codidact.com/posts/289829How to delete a local branch in git?Iizukihttps://software.codidact.com/users/649262023-09-28T08:19:17Z2023-09-29T06:54:31Z<p>How to delete a local git branch which hasn't been pushed to anywhere, and only exists locally?</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/289689How should open source forks, with a mix of upstreamable and non-upstreamable commits, be maintained?eoin.oneillhttps://software.codidact.com/users/654582023-09-14T02:12:12Z2023-09-25T21:23:16Z<p>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 upstreamab...https://software.codidact.com/posts/277862How do I customize merge behavior for a shared git repo?ajvhttps://software.codidact.com/users/532422020-09-01T21:42:19Z2023-09-14T02:34:33Z<p>I often find it useful to arrange things so that each commit on master's first-parent is a discrete change. It allows <code>git log --first-parent --oneline</code> to be used as a concise, autom...https://software.codidact.com/posts/289156`git submodule foreach git pull` in parallelmatthewsnyderhttps://software.codidact.com/users/613082023-07-30T19:23:34Z2023-09-09T17:18:24Z<p>I use <code>git submodule foreach git pull</code> to update my submodules. There's quite a few and it appears that <code>foreach</code> is updating them one by one, instead of in parallel. How c...https://software.codidact.com/posts/289655Reaching to a directory in git-bashBirbal01https://software.codidact.com/users/653842023-09-09T09:58:25Z2023-09-09T10:52:40Z<p>I have created a directory named <code>Temporary_add_to_version_control</code> on <code>Desktop</code>. Now I am trying to reach that directory by typing the following in git-bash:</p>
<pre><co...https://software.codidact.com/posts/289091How to move a tag in git?mr Tsjolderhttps://software.codidact.com/users/643002023-07-26T12:27:39Z2023-08-31T04:43:53Z<p>I have created a tag in my project, using <code>git tag v2023</code></p>
<p>However, I forgot to commit a few changes.<br>
Now I would like to move this tag to the current point (after having ...https://software.codidact.com/posts/289484Git: How to clone only a few recent commits?matthewsnyderhttps://software.codidact.com/users/613082023-08-21T16:26:54Z2023-08-23T15:05:20Z<p>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.</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/289505Clone .git repo into current dir, without touching filesmatthewsnyderhttps://software.codidact.com/users/613082023-08-22T21:25:50Z2023-08-22T21:27:16Z<p>I have git repo where the .git is deleted. I didn't realize it until after I made some changes to the code.</p>
<p>I want to re-create the <code>.git</code> by cloning. However I don't want it ...https://software.codidact.com/posts/289464Resolving "fatal: Unable to find remote helper for 'https'" and a warning about templatesMithicalhttps://software.codidact.com/users/80822023-08-20T18:29:46Z2023-08-20T18:29:46Z<p>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 <code>git</code>, and then <code>gh</code>, and making sure I was ...https://software.codidact.com/posts/289289Why is git merge from rather than to?matthewsnyderhttps://software.codidact.com/users/613082023-08-08T16:53:03Z2023-08-09T14:50:04Z<p>Why does <code>git merge</code> take the source branch rather than the destination branch as a parameter?</p>
<p>The most common merge case by far for me is "Okay, this branch looks good, let's...https://software.codidact.com/posts/289155How do I pull new changes in git submodules?matthewsnyderhttps://software.codidact.com/users/613082023-07-30T19:20:02Z2023-07-30T19:20:02Z<p>I have a git repository with some submodules.</p>
<p>When the submodule repos get new commits on the remote, how can I pull them all?</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/288764Possible drawbacks for having duplicate local sources of the project tracking the same Git remoteAlexeihttps://software.codidact.com/users/531772023-06-28T15:46:54Z2023-06-28T21:59:38Z<h2>Context</h2>
<p>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 ...https://software.codidact.com/posts/288690How to make Husky run git hook?LAFKhttps://software.codidact.com/users/635812023-06-24T00:38:13Z2023-06-24T07:02:46Z<p>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.</p>
<p>Not finding much luck, I then tried to ma...https://software.codidact.com/posts/284596What is HEAD in Git?hkotsubohttps://software.codidact.com/users/530782021-10-14T17:00:13Z2022-09-12T22:51:17Z<p>In Git documentation, <a href="https://git-scm.com/search/results?search=HEAD">there are lots of references to the term "HEAD"</a>.</p>
<p>But what exactly is it? Some places refer to it as "<e...https://software.codidact.com/posts/286835Keep local branch changes to resolve all remaining conflicts in a mergeQuasímodohttps://software.codidact.com/users/539192022-08-04T13:34:31Z2022-08-06T16:13:49Z<p>On branch-x, I do</p>
<pre><code class="language-none">git merge branch-y
</code></pre>
<p>Now there are some conflicts, and <code>git status</code> shows</p>
<pre><code class="language-none...https://software.codidact.com/posts/286726How to configure .gitignore to ignore all files except a certain directorymcphttps://software.codidact.com/users/568022022-07-15T22:23:07Z2022-07-16T01:38:18Z<h1>MWE</h1>
<p>In the terminal run:</p>
<pre><code class="language-sh">mkdir mwe
cd mwe
mkdir dir
touch f1.txt f2.pdf dir/f1.txt dir/f2.pdf
git init .
</code></pre>
<p>Create a <code>...https://software.codidact.com/posts/286573PGP sign emails sent with git-send-email(1)alxhttps://software.codidact.com/users/539372022-06-10T10:36:23Z2022-06-21T11:32:47Z<p>How can we use git-send-email(1) to sign patches (emails) with the gpg(1) keyring?</p>
<p>I've heard it can be done, but couldn't find anything in the git-send-email(1) documentation nor in a w...https://software.codidact.com/posts/286550Is it possible to undo a git reset?celtschkhttps://software.codidact.com/users/80562022-06-03T18:34:59Z2022-06-04T06:40:29Z<p>For some reason, I just wanted to undo a commit on my git repository, which I've done with the following command:</p>
<pre><code>git reset --soft HEAD~1
</code></pre>
<p>So far, so good. Howe...https://software.codidact.com/posts/286006Console scripts in virtual environment do not output to terminal in git bashboudewijn21https://software.codidact.com/users/547302022-02-22T11:35:44Z2022-04-21T09:33:51Z<p>I have console scripts in my virtual environment in <code>\env\Scripts</code>, installed with packages (e.g. black, pytest, coverage). If I try to execute these in Git Bash, the output is not re...https://software.codidact.com/posts/282752What's the correct way to merge a branch and its dependent branch back to master?Monica Celliohttps://software.codidact.com/users/80462021-07-23T18:06:46Z2022-01-10T14:01:26Z<p>In <code>git</code> 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 fe...https://software.codidact.com/posts/285366Conditionally ignore files in gitsamcarterhttps://software.codidact.com/users/363772021-12-23T13:51:05Z2022-01-06T17:11:08Z<p>I'm using git for LaTeX projects and am in a little dilemma about how to best ignore files.</p>
<ul>
<li>
<p>if I add <code>*.pdf</code> to my <code>.gitignore</code> file, I keep forgetting ...https://software.codidact.com/posts/284184Git deployment vs SFTP deploymentaditya98https://software.codidact.com/users/530052021-09-14T06:48:54Z2021-09-14T17:18:06Z<p>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 us...https://software.codidact.com/posts/283832Is it a good idea to have a permanent branch for a feature?Moshihttps://software.codidact.com/users/531962021-08-30T02:13:34Z2021-09-13T02:09:46Z<p>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 co...https://software.codidact.com/posts/283670How do I ask git-show-branch to display a commit range?ajvhttps://software.codidact.com/users/532422021-08-23T21:11:12Z2021-08-27T06:44:06Z<p>For some tasks, I find <code>git show-branch</code> easier to follow than <code>git log</code>. For example, inspecting the history on someone's PR before merging it.</p>
<p><code>git show-bran...https://software.codidact.com/posts/281341How can I find git branches where all branch-local commits are from specific people?Monica Celliohttps://software.codidact.com/users/80462021-04-12T18:21:28Z2021-04-14T04:45:59Z<p><a href=""></a>We have a bunch of dead branches in our git repository, and I'd like to clean them up. Ones that were merged (but not deleted at the time) are easy; we can see those in the branc...https://software.codidact.com/posts/277288How should we share some content between two otherwise-independent git repositories?Monica Celliohttps://software.codidact.com/users/80462020-08-16T20:06:16Z2021-02-18T02:49:45Z<p>We have two teams, dev and doc, and I'd like them to have shared access (via git) to a common subset of content. Specifically, I would like the examples that are used in the doc and that are sc...https://software.codidact.com/posts/279070How can I make --reset-author the default?Hyperlynxhttps://software.codidact.com/users/534452020-11-12T03:07:04Z2020-11-17T21:34:40Z<p>I do a lot of rebasing and amending of my topic branches. I don't think it's especially useful for me or my colleagues to see in the logs what date it was when I first started working on the par...https://software.codidact.com/posts/278539How do I configure Jenkins to strip the leading “origin/” in git branch parameter?Monica Celliohttps://software.codidact.com/users/80462020-10-15T15:47:37Z2020-10-16T17:14:31Z<p>I'm using Jenkins with a branch parameter to specify the branch to build from. Other stuff downstream needs the branch name to not have the leading "origin/" -- just "feature/blah...https://software.codidact.com/posts/277900How to protect the git respository for a public_html folder on a Linux server?Charlie Brumbaughhttps://software.codidact.com/users/81632020-09-03T19:22:22Z2020-09-03T19:44:16Z<p>On a Linux server, if you leave the .git folder unprotected in the public_html folder, its possible that someone could download the folder and then gain access to your files.</p>
<p>There are tw...