Today I Learned: Tuesday 7th June, 2022

Photo by Ross Stone on Unsplash

Today I Learned: Tuesday 7th June, 2022

  • Git and command line: I just used the git config tool to shorten the amount of time it takes to upload commits to github. I entered:\ git config --global alias.add-commit '!git add -A && git commit'

    • The config command allows you to configure some parts of using git in the command line.

    • The --global flag signifies that the following changes are to be made 'globally' across the computer. So not just for this file.

    • alias. is used to create a nickname for a command. I used add.commit as the nickname.

    • In the remainder of the command, we have '!git add -A && git commit'.

      • Notice the single quotation marks. Within those marks, is what will be inputted when you calle the alias. However, notice the ! before 'git'. I think this means that you the command should not include the word git when called on.

        • I'm not sure if this is the case or not, but why include !git in the first place if it is not to be included.
    • I also added another alias to shorten the time to check the git status.

    • git config --global alias.s '!git status'

  • If you want to commit some code to git, even though no changes has been made to the code since the last commit, you need to to use the parameter --allow-empty when entering the commit into the command line. Someone on stackoverflow suggested that there is rarely a need to do this though.

    • Similar to the --allow-empty parameter, the --allow-empty-message parameter allows you to make a commit without having to enter a message.

    • Git stash seems to be some way of stashing the changes made on a branch, when you you want to change to another branch. I'm still confused by this.

    • It first came up when I was in an alternative branch in VS Code.

    • I tried to save the file, but I received a warning saving this: "Your local changes would be overwritten by checkout"

    • Looks like you can save these stashes and give them messages.

    • I think you can even turn them into branches.

    • They are stored in index form, so the first one is stored in index 0.

      • And you can delete specific one by using the drop command. So

        • So use drop 2 to delete the third stash.
      • You can also use the pop command to delete the last stash, similar to how arrays work.

      • Looking at this video: How to change branch without losing your work, it looks like the term 'shelf' might be an alternative word to stash. I'm not sure what editor they're using though.

        • Now they're saying something abut this not being git, and some association with php.

        • Ah, I see they're using something called PHPstorm.

          • This isn't relevant for me. Exiting video.
      • A detached head in git is something got to the head pointing to a commit instead of a branch. Not sure what this means yet.

      • You can use the command line to stash code using 'git stash'.

    • Getting back to the error over it not saving, I solved it.

      • I just committed the code, and then I could switch back and forth.

      • So no need to stash or force anything.

        • I'll get back to learning about stashing eventually. But I'm going to get back to working on this code instead. (Go's crypto and encoding packages.)
  • Redmonk is a firm that provides rankings on programming languages.