• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

git

Git Remove Files From Repo After Commit

October 4, 2022

If you need to remove files from a repo after committing, use …

Remove file

git rm --cached file.ext

git rm --cached file.ext

Push to repo

git push

git push

Filed Under: Linux Tagged With: cache, commit, git, push, rm

Git Reset File From Master

May 28, 2022

Here’s how to reset a file from the master branch.

git checkout origin/master test.py

git checkout origin/master test.py

This will undo your changes and matches what’s in the master repo.

Filed Under: Git Tagged With: git, master, reset

Git Switch from HTTPS to SSH

January 20, 2022

If you have trouble cloning a github repo using https, you can tell it to switch to SSH instead.

Here’s the command.

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

I had to specify reconfigure when I ran terraform init.

terraform init --reconfigure

terraform init --reconfigure

Filed Under: Cloud, Linux Tagged With: clone, git, https, ssh, switch

Install Docker on Amazon Linux 2

December 11, 2021

Steps how to install Docker and Docker Compose on Amazon Linux 2.

Install Docker

$ sudo amazon-linux-extras install docker
$ sudo service docker start
$ sudo usermod -a -G docker ec2-user

$ sudo amazon-linux-extras install docker $ sudo service docker start $ sudo usermod -a -G docker ec2-user

Start at boot.

$ sudo chkconfig docker on

$ sudo chkconfig docker on

Install git (optional).

$ sudo yum install -y git

$ sudo yum install -y git

Install Docker Compose

$ sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) \
-o /usr/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

$ sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) \ -o /usr/bin/docker-compose $ sudo chmod +x /usr/local/bin/docker-compose

Check

docker --version
docker-compose --version

docker --version docker-compose --version

Filed Under: Linux Tagged With: amazon, docker, docker-compose, git, install

Git Clone Multiple Accounts

November 28, 2021

How to clone repositories with multiple Github accounts.

git clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git

git clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git

Filed Under: Linux Tagged With: accounts, clone, git, multiple, repo

Git Undo Add

October 13, 2021

To undo a git add, run git reset file or get reset.

git reset filename
git reset

git reset filename git reset

Run git status to check.

git status

git status

Filed Under: Linux Tagged With: add, git, reset, undo

AWS IAM Self Manage Policy

July 28, 2020

Here’s the permission needed for an AWS user to manage their own IAM account. The policy allows them to view their own account information, change their own passwords, rotate access keys and certificates, and manage their own git credentials.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowViewAccountInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetAccountPasswordPolicy",
                "iam:GetAccountSummary"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowManageOwnPasswords",
            "Effect": "Allow",
            "Action": [
                "iam:ChangePassword",
                "iam:GetUser"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnAccessKeys",
            "Effect": "Allow",
            "Action": [
                "iam:CreateAccessKey",
                "iam:DeleteAccessKey",
                "iam:GetAccessKeyLastUsed",
                "iam:ListAccessKeys",
                "iam:UpdateAccessKey"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnSigningCertificates",
            "Effect": "Allow",
            "Action": [
                "iam:DeleteSigningCertificate",
                "iam:ListSigningCertificates",
                "iam:UpdateSigningCertificate",
                "iam:UploadSigningCertificate"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnSSHPublicKeys",
            "Effect": "Allow",
            "Action": [
                "iam:DeleteSSHPublicKey",
                "iam:GetSSHPublicKey",
                "iam:ListSSHPublicKeys",
                "iam:UpdateSSHPublicKey",
                "iam:UploadSSHPublicKey"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Sid": "AllowManageOwnGitCredentials",
            "Effect": "Allow",
            "Action": [
                "iam:CreateServiceSpecificCredential",
                "iam:DeleteServiceSpecificCredential",
                "iam:ListServiceSpecificCredentials",
                "iam:ResetServiceSpecificCredential",
                "iam:UpdateServiceSpecificCredential"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        }
    ]
}

{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowViewAccountInfo", "Effect": "Allow", "Action": [ "iam:GetAccountPasswordPolicy", "iam:GetAccountSummary" ], "Resource": "*" }, { "Sid": "AllowManageOwnPasswords", "Effect": "Allow", "Action": [ "iam:ChangePassword", "iam:GetUser" ], "Resource": "arn:aws:iam::*:user/${aws:username}" }, { "Sid": "AllowManageOwnAccessKeys", "Effect": "Allow", "Action": [ "iam:CreateAccessKey", "iam:DeleteAccessKey", "iam:GetAccessKeyLastUsed", "iam:ListAccessKeys", "iam:UpdateAccessKey" ], "Resource": "arn:aws:iam::*:user/${aws:username}" }, { "Sid": "AllowManageOwnSigningCertificates", "Effect": "Allow", "Action": [ "iam:DeleteSigningCertificate", "iam:ListSigningCertificates", "iam:UpdateSigningCertificate", "iam:UploadSigningCertificate" ], "Resource": "arn:aws:iam::*:user/${aws:username}" }, { "Sid": "AllowManageOwnSSHPublicKeys", "Effect": "Allow", "Action": [ "iam:DeleteSSHPublicKey", "iam:GetSSHPublicKey", "iam:ListSSHPublicKeys", "iam:UpdateSSHPublicKey", "iam:UploadSSHPublicKey" ], "Resource": "arn:aws:iam::*:user/${aws:username}" }, { "Sid": "AllowManageOwnGitCredentials", "Effect": "Allow", "Action": [ "iam:CreateServiceSpecificCredential", "iam:DeleteServiceSpecificCredential", "iam:ListServiceSpecificCredentials", "iam:ResetServiceSpecificCredential", "iam:UpdateServiceSpecificCredential" ], "Resource": "arn:aws:iam::*:user/${aws:username}" } ] }

Filed Under: Cloud Tagged With: access, account, aws, certificates, change, credentials, git, iam, keys, manage, password, rotate

XCode after Catalina Upgrade

December 25, 2019

I tried running git after the Mac OS Catalina upgrade and got this error.

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Here’s the fix. For some very odd reason, Apple does not automatically reinstall xcode after each Mac OS upgrade.

You will need to either reset it or install it again.

# Try reset first
xcode-select --reset
# Or install it if reset doesn't work
xcode-select --install

# Try reset first xcode-select --reset # Or install it if reset doesn't work xcode-select --install

Close your terminal, and reopen and run git again.

Filed Under: Mac Tagged With: catalina, git, install, mac os, reset, xcode

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023