Devops - Git - Senario Based Taks.

1. Scenario  Based tasks :  
           
            Create the files , stage it , commit to local repo and move to remote repo
                        a. Create a new folder 
                          b. Put the following files in the folder
                                                             Code.txt
                                       Log.txt
                                    Output.txt
                          c. Stage the Code.txt and Output.txt files
                          d. Commit them
                          e. And finally push them to GitHub

1. Login to AWS Console ---

           Create the new instance – Confirm 2/2 check passed



2. Login server through putty :

            Switch to root user - sudo –i

            Update the server –   apt update

3. Install Git and check the version :

                           apt install git

                git --version

4. Create the folder and file :

Folder : mkdir git

                               Files  :    code.txt  , log.txt , output.txt

5. Add 3 files working directories to staging area :

                       Command :   git init   

                       Check the status :    git status



6. Move only Code.txt and Output.txt files to Staging area

·         git add Code.txt Output.txt – Check the status  - git status

7.  Commit our files from staging to local repo:

                    git commit –m “This is my new file”

       Now both files are in local repo


8. Create New id in Git Hub and configure credential globally:

         In server configure git username and password and confirm onces

                         git config --global user.name "K……..A"

                         git config --global user.email "……..@gmail.com"

                   git config –list




9.  Now to access the remote repository, we need credentials – Username and                                  Password as Token, Generated from github

     Login Git hub – Settings – In Developer settings  - Personal access tokens-    Generate the new token.


10.Create the new repository in Git hub  and clone with our local respository.

                                    git push origin master                                    

                                    git remote add origin “Url of github”

                                    git branch -M main

                                    git push -u origin main




 
  11. Now 2 files are moves to git hub:



2.. Scenario  Based tasks :  

                        Git Stash -  "git stash"  is a command in Git that allows you to temporarily save changes that you've made to your working directory, but that you are not yet ready to commit. This is useful if you need to switch branches or work on something else, but want to save your current work without committing it.

Task To Be Performed : 

 1.. Create a Git working directory with feature1.txt and feature2.txt in the master branch 

 2. Create 3 branches develop, feature1 and feature2 

 3. In develop branch create develop.txt, do not stage or commit it 

4. Stash this file and check out to feature1 branch 

5. Create new.txt file in feature1 branch, stage and commit this file

6. Checkout to develop, unstash this file and commit.


1. Created the new instance – logged in to the console through putty. 
              
               * Switch to root user – sudo -i 
               * Update the server – apt update


2. Installed git in the server:

                   apt install git



3. Created the 1 folder along with 2 files in master branch - feature1.txt , feature2.txt and  initialize git.


4. Create 3 branches – 1 .develop, 2 .feature1 3 .feature2


5. Created file in develop branch develop.txt and stash this file :

                            git stash 


6 . Now check out to branch : feature1 and created the new file and commit to local repository.



7. checkout to develop branch and unstash the file and commit to local repo.
  
                                  git stash pop



8. Now in developer branch is clean.






Comments

Popular posts from this blog

Important Interview Questions and Answere in Python.

Road Map for Devops - Entry Level , Intermediate Level and Expert Level.

Source Code Management --- GIT - Global Information Tracker