Please click here if you are not redirected within a few seconds.
Bitbucket › shanebow.com
Bitbucket

Git configuration

The git config command is used to get or set configuration at one of three levels:

  • git config --local [section.key] [value] Operates on the current project in the directory ./.git/config — This is the default.
  • git config --global [section.key] [value] Operates at the global level for the current user using the directory C:\Users\<username>\.gitconfig on Windows or ~ /.gitconfig on Unix.
  • git config --system [section.key] [value] Operates at the global level for the current user using the directory C:\ProgramData\Git\config on Windows or $(prefix)/etc/gitconfig on Unix.

In all of the above, when [value] is specified, you are setting the value for the section.key; otherwise you are retrieving the current setting.

Store Credentials

  • git config user.name [your username]
  • git config user.password [your password]

Checking Settings

To check configuration settings:

  • git config --list shows all the settings Git can find at that point.
  • git config <key> checks a specific key’s value
  • git config --show-origin <key> queries Git as to the origin for a value, and tells which configuration file had the final say in setting that value:

Download a Repo

  • git clone [url/to/reposity] will create the directory
  • or, git clone [url/to/reposity] [local-directory-name] if you want the local directory named something other than that of the remote directory
  • npm install to add node modules

See this Bitbucket article for more details including how to customize git colors in the terminal.


SSH Keys on Github (for AWS)

The way I found to generate keys with the correct format is to do it on Github

  • Generate the key set there and
  • import the private key to ssh client (bitvise)
  • upload the public key, ".pub" to the server (lightsail, AWS) at /home/your_home_dir/.ssh/authorized_keys.
  • Run chmod 640 authorized_keys

You should be able to ssh in with these settings:

Update Changes

  • cd [project/directory]
  • Check status: git status
  • Add (all) changed files to local: git add .
  • Commit the files to the local repo: git commit -m "some message"
  • Push the changes to the remote repo: git push
  • see 2.2 Git Basics - Recording Changes to the Repository

Sync local to remote

Basically, rewinds local changes, then pulls in remote changes, then replays local changes

  • cd [project/directory]
  • git fetch
  • git rebase

Create A New Repo from existing code

  • cd [project/directory]
  • Create the local repo: git init
  • Verify it is working: git status
  • Create a .gitignore file
  • Add all files (the dot means all): git add .
  • Commit the files to the local repo: git commit -m "initial commit"
  • Create a new (empty) remote repository on Bitbucket
    • Type is git
    • Easier if don't create a README
  • git remote add origin [bitbucket/URL]
  • git push -u origin master

Change the remote URL

Bitbucket may change the remote url of a repo out from under you when they upgrade their system.

If you get an error saying the remote repo does not exist, first check the url at your bitbucket account and verify that it is not the same as the setting on your computer:

  • git remote get-url origin

If there is a discrepancy, rectify it as follows:

  • Navigate to the repository: cd ~/[path/to/repo]
  • Display the current remote URL: git remote -v
  • Update the remote URL: git remote set-url origin git@bitbucket.org:tutorials/tutorials.git.bitbucket.org.git

Deleting a GitHub repository

  • On GitHub.com, navigate to the main page of the repository.
  • Under your repository name, click Settings.
  • Under Danger Zone, click Delete this repository.
  • Read the warnings.
  • To verify that you're deleting the correct repository, type the name of the repository you want to delete.Deleting a repository

VS Code

  • Open command Pallet (Shft Ctrl P)

Docs

GitHub Setup/Maintenance
Forking, Open Source, & Licenses