Tuesday, August 16, 2022

Git

Git Commands

-----------------------------------------------------------------------------------------------------------------------------

Company github Url: https://ibm.ghe.com
                                     https://Cybage.ghe.com
                                     https://Siemens.ghe.com
                                     https://Accenture.ghe.com

  • Create a Organizations
  • Creata a Repo
  • Create a Team
  • Add user to the team
  • Provide the Repo access to the team
git --version

git init ------------>Create a empty Git empty local repo.        (Head,Branch,config,hooks )

 Working Area                         Staging Area                                Local Repo   

Employee.java

Deploy.sh

Users.java

DBUtils.java

                 Arrow                       Arrow
                            git add *                                        git commit -m "Message<Fn_1>,<Fn_2>
                            git add .                                       
                         git add <Fn_1>,<Fn_2>                     

git status                                                           

git commit -m "Enter Your message here....!"
git commit -a -m "Enter Your message here....!"    (For modified Files only...)


git remote add wallmart https://github.com/Sundupalli/wallmart.git

git remote -v


git push (alias_name) master

git log -9 

git log  ------------>How  to know how many commits are there as of now.

                            HEAD:- Head is pointer, it is goint to indicate to the current working                                                          branch,latest commit.
What is the command to see how many files are commented in that perticular id?                         

git show <Commit_id> --->It will display on particular commit id how many files are commited.

git show --pretty="" --name-only <Commit_id> -------> Display only files name.

 Working Area                         Staging Area                                Local Repo 

                                                                  Employee.java

                                                                    Deploy.sh

                                                                    Users.java

                                                                    DBUtils.java

           left Arrow

   git  reset <Fn_1>



=======================================================================================

cleanup     (If we badly commeit the code, remove the commited code from remote Repo.it will delete the content also.)

git revert <Commit_id>

.gitignore

     .classpath
     .project
     .gitignore

What is different between  git reset & git revert ?             [Interview question]

git branch  ----------------------------------------------------->display branch list
git branch <custom_name>
git chekout development  -------------------------------> Switch to the branch
git chekout -b <br_name>--------------------------------> It will create a new branch and checkout.
git branch -m <old_name> <new_name> ------------>Renaming the branch name
git diff <br_name>
git diff <br_name> <br_name>
git merge <br_name>

git push  alias --all
git push master development stage

git branch      -----------------> Display Local Branch
git branch -r  -----------------> Display Remote Branch
git branch -a -----------------> Display Local & Remote Branch


git branch -d <Branch_Name>---------------------> To delete.

git push (alias_name) :<Branch_Name>


Pull Request:--- Integrate one branch to another branch in remote repo.


What is the difference between Branch & Tags?

Branch                                                              Tags
  1. Branch is Mutable                                      1.Tag is Immutable.
  2. We will create on going development        2. On producu deployment.
  3. Where ever we will created                        3. Only on master branch
  4. git branch <bn>                                          4. git tag <tn>
  5. git branch                                                    5.git tag
  6. git push <an><bn>                                      6. git push <an> tag <tn>
  7. git push <an> --all                                       7. git push <an> --tags
  8. git branch -d <bn>                                              8.git tag -d <tn>

git tag <tag_Name>------------------------------------> To create a new tag
git tag ------------------------------------------------------> display all tags
git push (alias_name) tag <tag_Name>---------> pushing into remote repo.
git push (alias_name) --tags------------------------>
git tag -d <tag_Name>--------------------------------> Delete tags.


git stash------------> if you want to jump to another branch without complete preset task.

git stash list

git stash apply

git stash drop

git stash pop ---------------------------------------> [apply + drop]

git stash apply stash{0}                               git stash drop stash{0}
git stash apply stash{1}                               git stash drop stash{1}
git stash apply stash{2}                               git stash drop stash{2}

git cherry-pick:

master
            |                                                        (Dc1=Development Commient)
            |
            |
           V   Development branch    (Dc1  Dc2  Dc3  Dc4 )
                                
git log
git cherry-pick CID

git clone  <Repo_Url>

git pull  -------------------------------> To get updated code from remote repo.
git fetch------------------------------->  Same as above.

git pull = git fetch + git merge


git fetch  (alias_name) <Branch_Name>

git merge  (alias_name) <Branch_Name>

How to communicate password less communication between Laptop and github?




1. Generate sshkey on your laptop----------------------------------> ssh-keygen
                                                                                                              id_rsa
                                                                                                              id_rsa.pub
                                                                                                              known_hosts
2.Check whether is available or not on my local laptop.--------> ls -la  ~/.ssh
3.copy the public key form ~/ .ssh
            cat ~/ .ssh/id_rsa.pub
4. goto github.
5. settings--------> SSH and GPG Keys--------> New SSK Key.
6. After add ssh key sucessfully,
7. check  ssh -T git@github.com
               ssh -T git@IBM.ghe.com
               ssh -T git@Siemens.ghe.com       
     
Where it will store?
        Users home direcotry
        ~/.ssh

Password less communication b/w Server to Server  ? ---------(Youtube---linux video)

HTTS Status Code

     200 -------------> OK ---> Sucessfull
     300 -------------> Redirect
Client Side Codes
    400 ------------->
    401 -------------> Unauthorised
    403 -------------> forbidden     (Enough access)
    404 -------------> not found
Server Side Codes
    500
    501
    502
    503
    504

How to map SSH Url?
  1. Copy SSH Url from
  2. git remote add Aliyas_name URL
HTTPs Url 

we need enter username & password
Instead of password we need to create PAT.  (Passsword we should not use it.)

PAT: Personal Access Token
  1. Go to Github Setting tab.
  2. Developer Settings--------> Personal Access Token-------> Generate New Token.
  3. Copy token information.
Git Rebase

master    Dc1  Dc2  Dc3  Dc4
            |                                                        (Dc1=Development Commient)
            |
            |
           V   Development branch    (Dc1  Dc2  Dc3  Dc4 )

Git merge

master    Dc5
            |                                                        (Dc1=Development Commient)
            |
            |
           V   Development branch    (Dc1  Dc2  Dc3  Dc4 )
Branching Strategy

development
         qa / Stage /  Pre-pd / UAT
          prod

        bugfix_Bugname          (We will create a branch from master branch)
        Feature_Featurename   (We will create a branch from master branch)
git config --global user.name "Ramadevi"
git config --globla user.email "sendmeanemail208@gmail.com"
git config --global --list














Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home