Git

GitHub is a SCM (Source Code Management)

Types of SCM:
  • Github
  • Bit bucket
  • GitHub
  • SVN
  • CVS
  • TFS
https://ibm.ghe.com  ---------------------------------------Enterprise Edition
https://github.com  -----------------------------------------Open Source

Admin Activities:
  • Create a Origination
  • Create a Repository
  • Create a Team
  • Add users to the Team
  • Provide Repository access to the Team.
Create a Team:
  • Your Origination
  • Teams
  • New Team
Provide Repository access to the Team:
  • Select the user (From the list)
  • Change role
  • Maintainer
  • Member
  • Add Repository to the team.

Git Commands:
git --version
git init
Working-Area                     Staging-Area                     Local-Repo
Untracked files                   Tracked files

Employee.java
Deploy.sh
DBUtils.java
                        Git add.                                    git commit - m “Your commit
                        Git add .
                        Git add Employee.java
  • git add .
  • git add *
  • git add <Filenames>
  • git commit  - m “your commit here.!”
  • git commit  - m “Your commit here.!”  <Filenames>
  • git commit  - m “Your commit here.!”  <Filenames> <Filenames>
  • git commit - - amend - m “Your new commit”---------------Change the most recent git commit message.
  • git commit  - a  - m “Your commit here.!” --------------------For modified files/ Existing files

Configure you email and user-name:
git config  - - global user.name “awstraining050”
git config  - - global user.email“awstraining040@gmail.com”
git config - - global  - -list



git remote add <alias name>  <GitHub-Url>
git remote – v ---------------------------------------------Check the remote URL mapped or not.

git remote add <Alias_Name> <SSH-Url>
git remote - v

git push <alias name> master

How to generate a token:
  • Settings
    • Development settings
      • Personal access tokens
        • Token (Classic)
          • Generate new token
          • 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
1.How to know how many commits are there?
        Git log

2.What is Head?
        Head is a pointer.
        Which is going to point to the currently working branch, in that branch latest commit id.

3.What is the command to see how many files are committed in that particular commit id?
        git show <Commit_id_Number>
        git show - - pretty=”” - - name-only  <Commit_id_Number>

Working-Area                     Staging-Area                     Local-Repo
git reset
git reset <File_Name>

4.Git revert?
        Whatever we are committed on particular id, all changes will be revoked.
        If you added the file that file will be delete.
        If you modified the information in existing file, that updated information also will be deleted.
       
         git revert  <Commit_id_Number>

5.What is the difference between git reset & git revert?
        git reset
        git revert

6.What is the difference between git & Gitlab?
7.Can we use git revert for older commit as well?


        IDE (Integrated Development Environment)
        Eclipse
        My Eclipse
        Intellij

        Visual Studio Code
        Atom

.gitignore
        .classpath 
        .project
        node_modules

Branch:

git branch
git branch -r
git branch -a
git branch -d <Branch_Name>
git branch  <Alias_Name>  : <Branch_Name>
git branch <Branch_Name>
git checkout <Branch_Name>
git diff <Branch_Name>
git merge <Branch_Name>-------------------------merge conflict


1.Is there any command to create the branch and checkout?
        git checkout - b  <Branch_Name>
2.How to push all branch in to remoter repository?
        git push <Alias_Name> - - all
        git push <Alias_Name> <Branch_Name>
3. How to integrate form one branch to another branch in remote repository?
        Pull Request
4. How to restore deleted branch?

Tag:

1. What is the difference between Branch & Tag?
Branch                                                                                  Tag
Branch is a Mutable                                                        Tag is an immutable (can’t change once created.)
We can create a number branch                                  we can create a production deployment.
Git branch <Branch_Name>                                          git tag <Tag_name>
Git branch                                                                         git tag
Git push <Alias_Name> <Branch_Name>                   git push <Alias_Name> tag <Tag_name>
Git push <Alias_Name> - -all                                         git push <Alias_Name> - - tags

2. Where Tags are created?  (On which branch)
        Master branch only

git tag <Tag_name><Version>
git tag  wallmartV1.0.0
git tag  - d <Tag_name> ------------------------To delete a tag

git Stash:
  • If you are working on “Development” Branch.
  • You got a call from your lead. You have to work on urgent task.
  • On this situation you need to switch the branch.
  • Whatever you have work on that information will save as a backup for temporary.
    • git stash
    • git stash list
    • git stash apply
    • git stash drop
    • git stash pop (apply + drop)
Git Cherry-Pick:
Git cherry-pick <Commit_ID>
Master
           |
           |
           Development Commint001, Commint002, Commint003, Commint001.
Git log
Git cherry-pick  Commint003


Git clone:
git clone <URL>

1. what is the difference between git pull & git fetch?

2. How to make password less communication between Laptop to GitHub server?                  
  • ssh-keygen ----------------------------------we need to generate keys
  • id_rsa
  • id_rsa.pub
  • user_home_directory/.ssh
  • ls - la  ~/.ssh
  • ssh -T git@github.com   -----------------For public
  • ssh -T git@ibm.ghe.com ----------------For Company
  • ssh <User_name>@<Host_Name>
  • ssh reddysekhar@172.12.6.22
3.How Password less ssh between 2 AWS EC2 instances using SSH Keys?

Git rebase:

Master|

             |

              Development Commint001, Commint002, Commint003, Commint001.

.

git merge ===git rebase  

(both are play same function)

Integrating from one branch to another branch.

Master cmt01 cmt02 cmt03 cmt04

            |

            |

             Development cmt01 cmt02 cmt03 cmt04



Branching Strategy:

Before going to live we need to check the performance of the application also for that also we need to create a one branch called “UAT”

For load testing / performance testing.

.

SIT (System Integration Test) is a one environment.

Before going to production as it is like production environment configurations are maintain.

SIT is similar to the production.

After production deployment we found error.

Direct we are not work on Master Branch.

We create a one branch name called “Bug fix_Bug_name”.

.

If any features are updated then we create a branch name called “Feature_Frature_Name”










Comments

Popular posts from this blog

AWS

Linux

kubernetes