0% found this document useful (0 votes)
62 views12 pages

Git - Interview Questions

Git is a distributed version control system that records changes to files in a software project as commits. It allows developers to work independently and merge their changes later. Git basics include commands like add, commit, push, log, status, show, blame and diff. Branching allows developers to work on features independently through feature branches, then merge them into the master branch. Merging may result in conflicts that need to be resolved. Rebasing makes feature branch changes appear as if they integrated directly with the master branch. GitHub is a web hosting service for Git repositories that provides a GUI interface and additional features.

Uploaded by

SimionMiltonJ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views12 pages

Git - Interview Questions

Git is a distributed version control system that records changes to files in a software project as commits. It allows developers to work independently and merge their changes later. Git basics include commands like add, commit, push, log, status, show, blame and diff. Branching allows developers to work on features independently through feature branches, then merge them into the master branch. Merging may result in conflicts that need to be resolved. Rebasing makes feature branch changes appear as if they integrated directly with the master branch. GitHub is a web hosting service for Git repositories that provides a GUI interface and additional features.

Uploaded by

SimionMiltonJ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

GIT:

AWS - Amazon Web Services - 23 services / 200+ - 6engs - nw/db/sto/app/ser/sec -


infra
DEVOPS - Automation(CI and CD PIPELINE) - Groovy , Plug-ins - CD, CVCS, CT, CM, CI,
CD
Case Study - Dark Launching - Single user base Test and deployment
SDLC - Software Development Lifecycle Model
1970 - WaterFall-Low; Agile-50% ; Devops - CI AND CD - 100%
VCS - It records the changes in terms of commitid; Local;Centralized;Distributed
GIT ARCHITECTURE - WorkingDirectory;Staging Area;Local Repository;Remote Repository
GIT - s/w;installation; CLI; Repository && Versioning tool - MASTER
GITHUB - Web Host; Third party Deployed one; GUI; Repository && Versioning Service
- REPLICA

GIT-SETUP - EC2 + GIT INSTALLATION


GIT CONFIGURATION - PRIVATE - 1 DEV TO 1 GIT SERVER(global) AND PUBLIC (many devs
to single git server) - no global
GIT BASIC COMMANDS - yum; git config; git status; git add ., git commit; git push;
git log; git blame; git show; git branch - 1 Master and Many
FB
git branch dev=>creates feature branch+copies source from M to
FB
git checkout master
git checkout dev

GIT BRANCH - M && F


GIT PUSH - Variable - Local Repository to Remote Repository
GIT MERGE - FROM MASTER git merge dev - mb
GIT PULL - Remote Repository to Local Repository = fetch + merge
= FETCH - RR to LR
= MERGE - LR to WD

GIT - CONFLICT MERGE - EXTRA COMM, additional commits reflecting only in master
MERGE TOOL
GIT - REBASE - PROACTIVE MONITORING - fb
GIT - STASH -
GIT - CHERRY-PICK- Picks particular commit from master to fb - FB
GIT - PULL - FETCHING FROM RR TO LR; MERGING LR TO WD...
GIT - CLONE - ENABLES HIGH LEVEL BACKUP OF THE SOURCE CODE
GIT - FORK - GITHUB

Staging Area - Buffer Location - post add - rm from sa or commit to lr - can't


apply back to wd
git stash - 1 2 3 4 - sa - buffer loca - we can apply back to wd

move - cut && paste


copy - copy && paste

QUESTIONS AND ANSWERS

GIT REVIEWS:
============

1. TRADITIONAL SYSTEM : backup


2. TYPES OF VCS:

3. GIT -

4. GIT :
GITHUB :

5. GIT FLOW :

6. GIT INSTALLATION :

7. GIT CONFIGURATION : Private - global

8. GIT - WORKING DIRECTORY :

9. GIT LOCAL REPOSITORY :

10. GIT BASIC COMMANDS :

11. GIT BRANCH : Master, feature branch,


git branch <name of feature branch>
git checkout <branch name>
git branch

12. GIT MERGE :

13. GIT REBASE :

14. GIT CHERRY-PICK :

15. GIT CLONE :

16. GIT PULL =

17. GIT PUSH :

18. GIT FORK :

19. GIT STASH :

20. STAGING AREA -


GIT STANSH -

21. WHICH SOURCE GIT CAN'T ADOPT?

22. INDUSTRY ADOPTION : 85%

GIT INTERVIEW QUESTIONS AND ANSWERS:


====================================
1 What is GIT ?
2 What is difference between GIT & Github ?
3 Why we use GIT ?
4 What is SCM & VCS ?
5 What are the process of pushing the code to GithubRepository ?
6 Why do we commit ?
7 What are the commands of GIT to push the code ?
8 How you can merge a git repository with another ?
9 What is branching in git ?
10 Different types of branching in GIT ?
11 What is merge conflict in git ?
12 How you can resolve merge conflict if you are merging same
13 project and in the same branch ?
14 What is merge conflict in git ?
15 What language is used in Git?
16 Name some of the popular Git hosting repositories.
GitHub
GitLab
BitBucket
Beanstalk
FogBugz
Surround SCM
Buddy

17 What is the diff between git reset and git revert?

18 Explain the git push command.

19 Explain the git pull command.


Git pull is used to fetch and merge changes from the remote repository
to the local repository. Git pull is a combination of two commands:
git fetch; followed by git merge.

20 What is Git stash?

21 Difference between git fetch and git pull.

22 How do you edit or fix the last commit message in Git?


"Ans.�If you forget to add anything in the commit message or committed a typo
error,
you can rectify it by using �amend flag command."

23 Why developers use Git Clone?

24 Will you create an additional commit or amend an existing commit?

25 Why do you use Subgit?

26 What's the difference between a bare and non-bare git repository?

27 How will you find out if a branch has already been merged or not?
"

Ans.�We use the following commands to find out if a branch has already been
merged or not:�
git branch �merged master � it will list all the branches that
have been renamed into master.
git branch �merged � it lists the branches that
have been merged into the current branch (HEAD).
git branch �no-merged �
it lists the branches that have not been merged.

"

28 What is the difference between Git stash apply and Git stash pop?

Old Reviews:
============
AWS Cloud computing: Services - from all 6 engs

Project management
- Fastest delivery of Software
- End to end Automation
- Development , testing , Production and DR --- ENVIRONMENTS => Who provide this
"AWS"
- Coding + testing + impl + end user access

SDLC Models

Traditional scm

Types of VCS

Diff CVCS and DVCS

Practicle:
1. EC2 Server - Linux : 65.0.179.147 ; ec2-user
2. Git installation
3. Git Configuration
4. Git commands

https://github.com/Akshiv20/straighttobank.git

Advanced:
=========

push:

1. branch
default branch - master or main
git branch dev
dev - feature branch creation
source also copied from master to dev branch

git checkout dev

2. merge
Normal merge - no problem -- base of master and dev are same
master: 1 2
dev : 1 2

merge conflict
master: 1 2 3 - merge conflict
dev : 1 2 4

==we are getting addionally one commit

3. rebase - execute from feature branch


proactive command

master: 1 2 3 4 merge into remote repo


dev : 1 2

dev: git rebase master


dev: 1 2 3 4

4. cherry-pick:
master: 1 2 3 4
dev : 1 2

dev: git cherry-pick 4commitid


master: 1 2 3 4
dev : 1 2 4

5. clone

6. pull = remote to master (local repository) - merge to working directory


git pull --allow-unrelated-histories https://github.com/Akshiv20/5-july-
project.git
pull = extract + merge

7. stash - buffer location, reapply source possible


staging area - delete or commit into local repo
git stash apply stashid = copy
git stash pop stashid = copy

8. fork

copy : source and des - ava


move : delete in source move to dest

master : merge command will be executed


git merge dev
GIT Review:
-----------
1. SDLC Models - Waterfall, Agile, devops
2. Devops stages: dev, test, deployment - continuous -
GIT, JENKINS, ANSIBLE, DOCKER, SPLUNK ---- Continuous
CI and CD Pipeline
"Facebook" - "Dark Launching" - "Single user base test"

3. Traditional source code managed -


local system management
backup annd recovery
rebuilt
collabration
no commit

4. Version Control system - Records the changes in terms of snapshot.

5. Types VCS
- Local : Version wise + locally maintained - backup and recovery
- Centralized : many devs to one single cen repo; Back and recovery; 100% net
- Distributed : Local repo + clone + copy of source code maintained here; GIT

6. GIT : Software - Local envi : CLI


GITHUB : Web Service - remote access : GUI
===> GITLAB, BIGBUCKET ....

7. Stages of GIT:
Working Directory
Staging Area
Local Repository
Remote repository

8. SET-UP:
1. EC2 SERVER CREATION
2. GIT SOFTWARE INSTALLATION
3. GIT CONFIGURATION
Types of Configuration
-> --global -- deticated to private user
-> Public git server -- anyone can access
4. git config -l
5. winscp - protocol --> local to remote server upload and download of source
codes
6. Working directory : mkdir mygit ; cd mygit
7. git init --> .git - hidden folder - Local repository
8. GITHUB - Remote repository - "Appropriate repository" - URL

9. vi sample.txt
git status => untracked or uncommited ; git add
git add . => source moved from wd to sa
git add filename
git add --all

git status?
git commit -m "first commit" => SA to LP
git status? Nothing to commit; on branch master or main push - source code
"sample.txt"

10. GITHUB - Repository creation


variable set-up for the repository
Push into Remote repository
git remote add variable_name <repository-url>
git push variable_name master

credentials: user name and password

11. git log --oneline


git log

git diff => diff b/w wd and sa


git diff --staged => diff b/w sa and lr

git blame filename => in detail history source code

git show commitid => tells commitwise information

GIT REVIEWS:
============

1. TRADITIONAL SYSTEM : Local system - sharing system , backup and recovery, no


version wise records, rebuilt

2. TYPES OF VCS: Local, centralized and distributed

3. GIT - Distributed, linus torvalds - linux kernel

4. GIT : software
GITHUB : web service

5. GIT FLOW : GIT = Working dir, staging area, local repo, GITHUB= remote repo

6. GIT INSTALLATION : yum install git ; 48mb

7. GIT CONFIGURATION : global (private) and without global (public - n no of devs


can use it)

8. GIT - WORKING DIRECTORY : mkdir <name of the directory>; cd <name of the dir>
9. GIT LOCAL REPOSITORY : git init --- .git (hidden dir)

10. GIT BASIC COMMANDS : add, commit, push, log, status, show, blame, diff

11. GIT BRANCH : Master, feature branch,


git branch <name of feature branch>
git checkout <branch name>
git branch

12. GIT MERGE : Master, push into remote repos,


Normal
merge conflicts - mergetool

13. GIT REBASE : run from feature branch


proactive
master - it will check and rebase it if required

14. GIT CHERRY-PICK : run from feature branch


only pick the required commitid to feature branch

15. GIT CLONE : Backup and recovery ; testing

16. GIT PULL = Extract + Merge


git pull allow-unrelated-histories <repos name>

17. GIT PUSH : local to remote pushing ; variable setting

18. GIT FORK :

19. GIT STASH : buffer location, when we unsure we can use this and reuse the
source code unlike staging area

20. STAGING AREA - Delete or commit into local repo


GIT STANSH - reuse it

21. WHICH SOURCE GIT CAN'T ADOPT?


.exe

22. INDUSTRY ADOPTION : 80%

git remote set-url vari git@github.com:Akshiv20/automate_repo.git

git - Distributed Vcs


---------------------
1. push - token
2. Branch - Master and feature branch
3. Normal Merge

4. Conflict merge - Extra Commit -


5. rebase - Proactive Rebase Mechanism
6. cherry-pick - Picking up
7. stash - Staging Area {Buffer location, [rm or com to LR]}
8. pull -
9. clone -
10. fork

1 clear
2 git --version
3 git config --global user.name �Akshiv20�
4 git config --global user.email �queenprince20@gmail.com�
5 git config --global core.editor vim
6 git config --global core.compression 2
7 git config --global diff.tool vim.diff
8 git config -l
9 mkdir workdir
10 cd workdir/
11 git init
12 clear
13 git branch
14 vi sample
15 git status
16 git add sample
17 git status
18 git branch
19 git commit -m "First Commit"
20 clear
21 git branch
22 git log --oneline
23 git branch dev
24 git branch
25 git checkout dev
26 git branch
27 git log --oneline
28 vi sample
29 git commit -am "Second Commit"
30 git log --oneline
31 git checkout master
32 git log --oneline
33 git merge dev
34 clear
35 git brancg
36 git branch
37 git log --oneline
38 git branch
39 git checkout dev
40 git checkout master
41 git remote add origin https://github.com/akshiv2011/Veralevel.git
42 git remote -v
43 git push origin master
44 clear
45 git branch
46 git log --oneline
47 git checkout dev
48 git log --oneline
49 git checkout master
50 vi sample
51 git commit -am "Third Commit Fro mMaster"
52 git log --oneline
53 git checkout dev
54 git log --oneline
55 vi sample
56 git commit -am Commit from Feature Branch"
57 clear
58 git commit -am "Commit from Feature Branch"
59 git log --oneline
60 git checkout master
61 git merge dev
62 git config --global merge.toolvimdiff
63 git config --global merge.conflictstyle diff3
64 git config --global mergetool.prompt false
65 git mergetool
66 clear
67 git branch
68 git merge dev
69 git commit -am "Extra merge Commit - 5"
70 git log --oneline
71 history
72 clear
73 git log --oneline
74 git branch
75 git checkout dev
76 git log --oneline
77 git rebase master
78 git log --oneline
79 clear
80 cd ..
81 mkdir workd
82 cd workd
83 git init
84 clear
85 vi cher
86 git commit -am "1 com"
87 git status
88 git add cher
89 git commit -m "1 com"
90 clear
91 git branch
92 git checkout fea
93 git branch fea
94 git checkout fea
95 git log --oneline
96 git checkout master
97 vi cher
98 git commit -am "2 com"
99 vi cher
100 git commit -am "3 com"
101 git log --oneline
102 git checkout fea
103 git log --oneline
104 git cherry-pick 5353e43
105 clear
106 git branch
107 git log --oneline
108 git rebase master
109 git log --oneline
110 CLEAR
111 clear
112 git branch
113 vi cher
114 git stash
115 git stash list
116*
117 git stash
118 git stash list
119 git stash pop stash@{1}
120 git stash list
121 ls
122 vi cher
123 clear
124 cd -
125 ls
126 pwd
127 git clone https://github.com/akshiv2011/Veralevel.git
128 ls
129 cd Veralevel
130 ls
131 rm -rf Training.xlsx
132 ls
133 git pull https://github.com/akshiv2011/Veralevel.git
134 cd ..
135 clear
136 ls
137 mkdir vl2
138 git init
139 cd vl2/
140 git init
141 clear
142 vi sour
143 git add .
144 git commit -m "1 com"
145 git remote add var https://github.com/akshiv2011/veraleveltwo.git
146 git push var master
147 cd ..
148 ls
149 cd Veralevel
150 ls
151 git pull https://github.com/akshiv2011/veraleveltwo.git
152 clear
153 git pull --allow-unrelated-histories
https://github.com/akshiv2011/veraleveltwo.git
154 ls
155 clear
156 history

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy