441 Matching Annotations
  1. Jun 2025
    1. commits a los repositorios

      Me parece súper importante porque así se puede ver si alguien hizo cambios después de las indicaciones o si siguió las reglas que se dieron.

      Un commit es una acción en sistemas de control de versiones (como Git) que guarda los cambios realizados en los archivos de un proyecto dentro del repositorio. Es como tomar una “foto” del estado actual del código para poder revisarlo, compartirlo o revertirlo en el futuro.

  2. May 2025
  3. Apr 2025
    1. annotated tags point to a tag object in the object database. git tag -as -m msg annot cat .git/refs/tags/annot contains the SHA of the annotated tag object: c1d7720e99f9dd1d1c8aee625fd6ce09b3a81fef and then we can get its content with: git cat-file -p c1d7720e99f9dd1d1c8aee625fd6ce09b3a81fef
    1. I would argue that "whole tree" thinking is enhanced by --follow being the default. What I mean is when I want to see the history of the code within a file, I really don't usually care whether the file was renamed or not, I just want to see the history of the code, regardless of renames. So in my opinion it makes sense for --follow to be the default because I don't care about individual files; --follow helps me to ignore individual file renames, which are usually pretty inconsequential.
  4. Mar 2025
  5. Feb 2025
  6. Oct 2024
  7. Sep 2024
  8. Jul 2024
  9. Jun 2024
  10. May 2024
    1. An alternative approach would be to rebase the "top" of the stack, part-3 on top of dev. We could then reset each of the branches to the "correct" commit in the newly-rebased branch, something like this:
  11. Apr 2024
    1. However, as we want to do perform the bisection automatically using as criterion ./calc.py 14 0, we run git bisect run ./calc.py 14 0

      git bisect run ./calc.py 14 0 ← example of running git bisect automatically. * If the commit is good, then the command should return 0; * If the commit is bad, then the command should return anything between 1 and 127, inclusive, except 125; * If it is not possible to tell if this commit is good or bad, then it need to be ignored, and the command should return 125.

    2. Git Bisect! It allows us to find the commit that broke something. Given a “good” commit (a commit that is not broken, created before the introduction of the bug), and a “bad” commit (a commit that certainly is broken), Git will perform a binary search until the broken commit is found.

      Git Bisect can be run manually or automatically

    3. What are the tools that comes on your mind when someone say “debug”? Let me guess: a memory leak detector (e.g. Valgrind); a profiler (e.g. GNU gprof); a function that stops your program and gives you a REPL (e.g. Python’s breakpoint and Ruby’s byebug); something that we call a “debugger” (like GDB, or something similar embedded on the IDEs); or even our old friend, the print function. So, in this text I’ll try to convince you to add Git to your debug toolbelt.

      6 differen debugging tools

  12. Mar 2024
  13. Feb 2024
    1. if (!stat(worktree_git_path(wt, "rebase-apply"), &st)) { if (!stat(worktree_git_path(wt, "rebase-apply/applying"), &st)) { state->am_in_progress = 1; if (!stat(worktree_git_path(wt, "rebase-apply/patch"), &st) && !st.st_size) state->am_empty_patch = 1; } else { state->rebase_in_progress = 1; state->branch = get_branch(wt, "rebase-apply/head-name"); state->onto = get_branch(wt, "rebase-apply/onto"); } } else if (!stat(worktree_git_path(wt, "rebase-merge"), &st)) { if (!stat(worktree_git_path(wt, "rebase-merge/interactive"), &st)) state->rebase_interactive_in_progress = 1; else state->rebase_in_progress = 1; state->branch = get_branch(wt, "rebase-merge/head-name"); state->onto = get_branch(wt, "rebase-merge/onto"); } else return 0; return 1;

    1. git remote set-head origin -a

      Resolved the problem I had where I mistakenly deleted this [local tracking branch]?

      ls .git/refs/remotes/origin/HEAD ls: cannot access '.git/refs/remotes/origin/HEAD': No such file or directory

    1. You should never rely on the presence or contents of anything under the .git directory. That's git's territory, not yours or the build system's. Use it's plumbing commands to get access to the information you need, rather than trying to read files directly. Git provides no guarantee about the location or contents of any of those files as far as I'm aware.
    1. The increment-after-release model makes sense for branching too. Suppose you have a mainline development branch, and you create maintenance branches for releases. The moment you create your release branch, your development branch is no longer linked to that release's version number. The development branch contains code that is part of the next release, so the version should reflect that.
    1. git diff 本身只显示尚未暂存的改动,而不是自上次提交以来所做的所有改动。

      比较的是工作目录中当前文件和暂存区域快照之间的差异,若要查看已暂存的将要添加到下次提交里的内容,可以用 git diff --staged 命令

  14. Jan 2024
  15. Dec 2023
  16. Oct 2023
  17. Sep 2023
  18. Aug 2023
  19. Jul 2023
  20. Jun 2023
    1. Instead of manually backtracking what changes each developer made, three-way merge does just that for us! This is because modern version control systems, such as Git, can automatically find what's known as the "nearest common ancestor", aka base revision (or merge-base). It is called "3-way" since it uses three revisions to produce a final merged version.

      3-way merge

  21. May 2023
  22. Apr 2023
  23. Mar 2023
    1. Small Collision Probabilities

      How probable is for some git hash-ids (some chars, not the full length) to collide:

      • for a small project with ~100 commits:

        • 8 digits (32bits): 1/million
        • 7 digits (28bits): 1/54,000
        • 6 digits (24bits): 1/3,400
      • for a big project: with ~10.000 commits:

        • 8 digits: 1/100
        • 7 digits: 1/6
        • 6 digits: ~1

      As confirmed with the vecto repo, with these ipython commands: ```ipython

      !git rev-list --all --count 14042 def collissions(k,N): ...: return 1 - e((-k(k-1)/(2N)))

      collissions(14042, 16**6) 0.9971938358691735 !git rev-list --all | cut -c -6 | sort | uniq -cd 2 5af40d 2 6a6c62 2 914c24 2 d83979 2 e8060f

      collissions(14042, 16**7) 0.3073608000674162 !git rev-list --all | cut -c -7 | sort | uniq -cd 2 e8060f9

      collissions(14042, 16**8) 0.022691464724788335 !git rev-list --all | cut -c -8 | sort | uniq -cd <nothing> ```

    1. ```sparql PREFIX wd: http://www.wikidata.org/entity/ PREFIX gist: https://ontologies.semanticarts.com/gist/ PREFIX dcterms: http://purl.org/dc/terms/

      SELECT DISTINCT ?commitTitle ?commitTime ?filename ?textLine WHERE {

      ?commit a wd:Q20058545 ; # it's a commit gist:hasPart ?part ; dcterms:subject ?commitSubject ; gist:atDateTime ?commitTime .

      ?commitSubject dcterms:title ?commitTitle .

      ?part gist:produces ?contiguousLines .

      ?contiguousLines gist:occursIn ?file ; http://example.com/containedTextContainer ?textContainer .

      ?file gist:name ?filename . ?textContainer ?line ?textLine .

      FILTER(contains(?textLine,"music")) } ```

  24. Feb 2023
  25. Jan 2023
    1. For ordinary commits, it's trivially obvious what to compare: compare this commit's snapshot to the previous (i.e., parent) commit's snapshot. So that is what git show does (and git log -p too): it runs a git diff from the parent commit, to this commit. Merge commits don't have just one parent commit, though. They have two parents.1 This is what makes them "merge commits" in the first place: the definition of a merge commit is a commit with at least two parents.
  26. Dec 2022
    1. Your changes preserved through git stash are saved in your project’s .git directory, usually, the path is /.git/refs/stash

      Location where git stash saves files

  27. Nov 2022
    1. It is handy to manually generate the diagram from times to times using the previously created command: npm run db:diagram:generate. Though, getting the diagram to update itself on its own automatically without a developer interaction would ensure that it the diagram is never obsolete. There are several ways of doing this.You could use a pre-commit git hook or even better simply configure your CI/CD pipeline(s) to run the npm script whenever something gets merged into the main branch 🙂
    1. Changing the second line to: foo.txt text !diff would restore the default unset-ness for diff, while: foo.txt text diff will force diff to be set (both will presumably result in a diff, since Git has presumably not previously been detecting foo.txt as binary).

      comments for tag: undefined vs. null: Technically this is undefined (unset, !diff) vs. true (diff), but it's similar enough that don't need a separate tag just for that.

      annotation meta: may need new tag: undefined/unset vs. null/set

  28. Oct 2022
  29. Sep 2022
    1. If you want to replace many blobs, trees or commits that are part of a string of commits, you may just want to create a replacement string of commits and then only replace the commit at the tip of the target string of commits with the commit at the tip of the replacement string of commits.
    1. As of Git 1.6.5, the more flexible git replace has been added, which allows you to replace any object with any other object, and tracks the associations via refs which can be pushed and pulled between repos.
  30. Aug 2022
    1. # Do this the first time: $ git remote add -f -t master --no-tags gitgit https://github.com/git/git.git $ git subtree add --squash --prefix=third_party/git gitgit/master # In future, you can merge in additional changes as follows: $ git subtree pull --squash --prefix=third_party/git gitgit/master # And you can push changes back upstream as follows: $ git subtree push --prefix=third_party/git gitgit/master # Or possibly (not sure what the difference is): $ git subtree push --squash --prefix=third_party/git gitgit/master
  31. Jul 2022
  32. Jun 2022
    1. Git also has a built-in command (maintenance) to optimize a repository’s data, speeding up commands and reducing disk space. This isn’t enabled by default, so we register it with a schedule for daily and hourly routines.

      git maintenance

    1. Remove the commit from step 2. We will merge ignoring the failure. Remove the commit from the other, check it passes with the other commit now on main. Merge the other. We will trigger builds for the main branch of affected repositories to check if everything is in order. Steps 5-8 should happen continuously (e.g. one after another but within a short timespan) so that we don't leave a broken main around. It is important to triage that build process and revert if necessary.

      It is important to not leave a broken main around.

  33. May 2022
    1. A properly formed Git commit subject line should always be able to complete the following sentence:If applied, this commit will your subject line hereFor example:If applied, this commit will refactor subsystem X for readability

      An example how to always aim for imperative commits

    2. Git itself uses the imperative whenever it creates a commit on your behalf.For example, the default message created when using git merge reads:Merge branch 'myfeature'

      Using imperative mood in subject line of git commits

    3. Commit messages with bodies are not so easy to write with the -m option. You’re better off writing the message in a proper text editor.

      I've tested it on Windows, and in PowerShell or Git Bash it is as simple as:

      ```console git commit -m "Subject line<ENTER>

      body line 1 body line 2"<ENTER> ```

      However, it does not work in CMD.exe (pressing [ENTER] will not move to the next line)

    4. Firstly, not every commit requires both a subject and a body. Sometimes a single line is fine, especially when the change is so simple that no further context is necessary.

      Not every commit requires a body part

    5. Summarize changes in around 50 characters or less More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of the commit and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); various tools like `log`, `shortlog` and `rebase` can get confused if you run the two together. Explain the problem that this commit is solving. Focus on why you are making this change as opposed to how (the code explains that). Are there side effects or other unintuitive consequences of this change? Here's the place to explain them. Further paragraphs come after blank lines. - Bullet points are okay, too - Typically a hyphen or asterisk is used for the bullet, preceded by a single space, with blank lines in between, but conventions vary here If you use an issue tracker, put references to them at the bottom, like this: Resolves: #123 See also: #456, #789

      Example of a great commit message

    6. Separate subject from body with a blank lineLimit the subject line to 50 charactersCapitalize the subject lineDo not end the subject line with a periodUse the imperative mood in the subject lineWrap the body at 72 charactersUse the body to explain what and why vs. how

      7 rules of great commit messages

  34. Apr 2022
    1. The eagle-eyed among you may notice that there isn't a .git directory in the app-example-2 working tree. Instead, there's a .git file. This file points to the git directory in the original clone, and it means that all your usual git commands work inside the app-example-2 directory, as well as in the original app-example directory.

      The working of git worktree

    2. Anecdotally, I've found IDEs get much less "confused" if you use their built-in support for switching git branches, instead of changing them from the command line and waiting for the IDE to "notice" the changes.
    1. GIT_INDEX_FILE is the path to the index file (non-bare repositories only).

      export GIT_INDEX_FILE=".git/index.linux" if you are working on Linux

      export GIT_INDEX_FILE=".git/index.windows" if you are working on Linux

  35. Mar 2022
    1. Flatpak is built on top of a technology called OSTree, which is influenced by and very similar to the Git version control system. Like Git, OSTree allows versioned data to be tracked and to be distributed between different repositories. However, where Git is designed to track source files, OSTree is designed to track binary files and other large data.
    1. $ git config --list http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt http.sslbackend=openssl diff.astextplain.textconv=astextplain core.autocrlf=true core.fscache=true core.symlinks=false credential.helper=manager user.name=xxj user.email=hea@exa.com credential.helper=store credential.username=xxxj core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true remote.origin.url=ssh://@192.168.2.172:29418/hea_storage_model.git remote.origin.fetch=+refs/heads/:refs/remotes/origin/ branch.master.remote=origin branch.master.merge=refs/heads/master

      此种配置下, git push 出现如下提示:

      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights and the repository exists.

      检查后发现,有问题的配置项:

      remote.origin.url=ssh://@192.168.2.172:29418/hea_storage_model.git

      remote.origin.url=ssh://@ 缺少了 username

  36. Feb 2022
    1. Can't annotate the comments for some reason, so I am copying the below:

      The Jerk talked about getting hit by a bus, etc. I said who cares about code if a guy’s in hospital or there’s a war, we’ve got better things to worry about than a few days of lost code.

      I feel the pain. I do. I understand. I get scared. I want to check in early and often, but source control isn’t your personal unlimited undo. When I look at history I don’t want to see rubbish. I want to see snapshots of working code.

      Don’t hold back, and don’t go dark, but use your f’ing head. It’s far better to locally integrate multiple times per day and merge back after a few days because guess what, no surprises.

    1. You have just told Git to combine all seven commits into the first commit in the list. It's now time to give it a name: your editor pops up again with a default message, made of the names of all the commits you have squashed

      Put the message you like.

    2. mark all the commits as squashable, except the first/older one: it will be used as a starting point

      After git rebase -i HEAD~N or

      git rebase -i [commit-hash] your editor of choice will pop up, showing the list of commits you want to merge and you'll mark a commit as squashable by changing the word pick into squash next to it (or s for brevity, as stated in the comments).

    3. The first thing to do is to invoke git to start an interactive rebase session

      git rebase --interactive HEAD~N # or -i where N is the number of commits you want to join, starting from the most recent one.

    4. It's a handy tool I use quite often; I usually tidy up my working space by grouping together several small intermediate commits into a single lump to push upstream.

      Could be a good practice. During work, I'll commit small chunks of work but when the feature is done they are put together to facilitate code review.

    1. Changing an Older or Multiple Commits

      git rebase -i HEAD~N # N is the number of commits * The command will display the latest X commits in your default text editor; * Move to the lines of the commit message you want to change and replace pick with reword; Save the changes and close the editor; * For each chosen commit, a new text editor window will open; * Change the commit message, save the file, and close the editor; * Use --force in case of pushed commits.

    2. Generally, you should avoid amending a commit that is already pushed as it may cause issues to people who based their work on this commit. It is a good idea to consult your fellow developers before changing a pushed commit.

      Take care ammending pushed commits

  37. Jan 2022
  38. Dec 2021
    1. it is best to limit the number and scope of branches in your repository. Most implementations suggest that developers commit directly to the main branch or merge changes from their local branches in at least once a day.

      Actually this is the "agile" motto - release early, so no long feature-branches.

  39. Nov 2021
    1. Here are the impressive detailed statistics from their repository as of 2015, for which more recent data is challenging to obtain.

      Interesting statistics (mostly inside diagrams) from 2015 on Google's big [[monorepo]] (which is NOT git).

    1. The overall flow of Gitflow is: A develop branch is created from main A release branch is created from develop Feature branches are created from develop When a feature is complete it is merged into the develop branch When the release branch is done it is merged into develop and main If an issue in main is detected a hotfix branch is created from main Once the hotfix is complete it is merged to both develop and main

      The overall flow of Gitflow

  40. Oct 2021
    1. Hotfix branches are a lot like release branches and feature branches except they're based on main instead of develop. This is the only branch that should fork directly off of main. As soon as the fix is complete, it should be merged into both main and develop (or the current release branch), and main should be tagged with an updated version number.

      Hotfix branches

    2. Once develop has acquired enough features for a release (or a predetermined release date is approaching), you fork a release branch off of develop. Creating this branch starts the next release cycle, so no new features can be added after this point—only bug fixes, documentation generation, and other release-oriented tasks should go in this branch. Once it's ready to ship, the release branch gets merged into main and tagged with a version number. In addition, it should be merged back into develop, which may have progressed since the release was initiated.

      Release branch

    3. feature branches use develop as their parent branch. When a feature is complete, it gets merged back into develop. Features should never interact directly with main.

      Feature branches should only interact with a develop branch

    4. When using the git-flow extension library, executing git flow init on an existing repo will create the develop branch

      git flow init will create:

      • feature branch
      • release branch
      • hotfix branch
      • support branch
    1. The main condition that needs to be satisfied in order to use OneFlow is that every new production release is based on the previous release. The most difference between One Flow and Git Flow that it not has develop branch.

      Main difference between OneFlow and Git Flow

    2. The most difference between GitLab Flow and GitHub Flow are the environment branches having in GitLab Flow (e.g. staging and production) because there will be a project that isn’t able to deploy to production every time you merge a feature branch

      Main difference between GitLab Flow and GitHub Flow

    3. release-* — release branches support preparation of a new production release. They allow many minor bug to be fixed and preparation of meta-data for a release. May branch off from develop and must merge into master anddevelop.

      release branches

    4. hotfix-* — hotfix branches are necessary to act immediately upon an undesired status of master. May branch off from master and must merge into master anddevelop.

      hotfix branches

    5. feature-* — feature branches are used to develop new features for the upcoming releases. May branch off from develop and must merge into develop.

      feature branches

  41. Sep 2021