DevOps Classroom Series – 27/Nov/2021

Git Contd..

  • Lets create a new linux vm and try to configure git in this
  • Configure the username and email Preview
  • Git Configurations: Git has three config levels
    • --local:
      • These configs are local to your repository and will be stored .git/config
    • --global:
      • This Configuration is user specific in an operating system
      • On linux or mac systems ~/.gitconfig Preview
      • On Windows ~\.gitconfig => ~ => C:\users\<username>
    • --system:
      • This is configuration for the entire machine i.e. for all the users and all the repos
      • Linux: /etc/gitconfig
      • Windows: <git-install-root>\mingw64\etc\gitconfig
  • When we have same configuration defined in different levels then the precedence
local > global > system
  • Lets create a local config with username and email, Now create a new commit Preview Preview
  • There are configurations which you can set Refer Here
  • Exercise:
    • Install Beyond compare or any other diff which you are comfortable with and configure it as local setting for your repository to use beyond compare as diff tool
    • Change the editor for the local repository to notepad or notepad++ or sublime text or vscode on your windows

Aliases

  • We can define aliases for the commands which we reuse often
  • Lets try to create an alias for the following command git log --graph --decorate --pretty=oneline --abbrev-commit
  • Let create an alias called as history `git config –global alias.history ‘log –graph –decorate –pretty=oneline –abbrev-commit’ Preview Preview Preview

Git Protocols

  • Git can communicate with four protocols

    • Local
    • Http/Https:
      • Authentication will be
        • username/password:
        • token based authentication: GitHub has moved to token based authentication Preview
    • Secure Shell (SSH):
      • This is authenticate protocol which comes with advantage of being easy to setup
      • Setup:
        • Create a key-pair ssh-keygen Preview
        • Now copy your public key contents to your server
        • This for github
    • Git:
      • This is one of the fastest protocols, however lacks robust authentication feature, generally suitable for read-only access to public projects.
  • Note: In GitHub to create PAT Refer Here

Git attributes

  • Git attributes define the paths so that git treats the files as binary or text and what language to use for syntax highlighting.
  • To create git attributes in the repo we will create .gitattributes
  • Refer Here for the collection of useful git attributes

Git Ignore

  • This specifies intentionally untracked files to ignore
  • To create a ignore specification create .gitignore file
  • In the .gitignore file specify the files and folders which you want to ignores which you want to ignore
  • We can generate .gitignore contents for all the popular language Refer Here
  • Refer Here for the changeset to ignore the unnecessary files from your repo

Setting Upstream

  • When you set up local repo first and then push the changes then we need to set the upstream Preview
  • To push a branch to remote repo Preview Preview Preview

Adding multiple Remote Repositories

  • Look at the below example Preview
  • Conceptual overview Preview

Bare Repositories

  • A bare repository will have only .git folder and it doesn’t have the working tree
  • To create a bare repo
git init --bare

Preview Preview

  • This bare repository can be used by others to clone and submit commits to that Preview
  • Cloning from remote as bare repository Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube