Skip to content

Commit ea6159b

Browse files
committed
git files
1 parent 39c7481 commit ea6159b

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

GIT/Branching-realtimeScenario.txt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Lets see the usages of Git Branching with real-world examples including how to create a branch, update it, delete it, switch to another branch, and merge them locally and remotely.
2+
3+
Most of the software projects have two mainstream branches as master and dev.
4+
5+
The master branch is used for ready for production changes and the dev branch is used for testing purposes.
6+
7+
When new changes are tested on the dev branch, eventually it will be merged into the master branch and finally, we will take a deployment on the master branch.
8+
9+
we should work neither on the master branch nor on the dev branch directly. For every tiny or massive change in a software project, we should first create a new branch from the dev branch by naming the new branch related to our new change.
10+
11+
12+
Let me assume that we already have a GitHub repository.
13+
14+
And you can see we have only the “master” branch which is created by default.
15+
16+
Setting Remote and Local Branches
17+
18+
Branch on Remote
19+
20+
But as most software projects have common branches as master and dev. Click on branch section and By typing “dev” and clicking the appeared “Create branch: dev” section, we can create the dev branch on the remote repository.
21+
22+
Create a Branch on Local Repository
23+
24+
git pull origin dev
25+
26+
git branch ==> master and dev branch will be there in local repo
27+
28+
29+
Switching branches
30+
31+
Now we are ready for development and just before starting, we need to change our current branch from master to dev by using git command on our local repository.
32+
33+
git checkout dev
34+
35+
The dev branch which will be our main development branch. All development operations will be originated from that branch.
36+
37+
Now Let us create a new branch from the dev branch
38+
39+
git branch my-bugfix
40+
41+
Now make changes to your branch and commit the changes
42+
43+
push the branch to github
44+
45+
git push origin my-bugfix
46+
47+
After pushing our commit with our new branch, we can check the remote repository from the branches section. You could see the new branch
48+
49+
50+
Once you work on branch is complete, you can delete it
51+
git branch -D my-new-branch
52+
53+
Delete a branch on Remote repo
54+
55+
git push origin --delete my-bugfix
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+

GIT/GIT-repo Example.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
We have 2 GIT hub users :
2+
3+
User 1: sonal0409
4+
User 2: sonal04devops
5+
6+
Execute the below steps to see how git fork and clone works.
7+
8+
> Sonal0409 is the owner of a repo - https://github.com/Sonal0409/myprojectmar.git
9+
10+
> sonal04devops is a new developer in her team and he has to implement new features and contribute to the master source code repo.
11+
12+
Here are the steps he needs to follow:
13+
14+
> Fork the repo : of sonal0409. https://github.com/Sonal0409/myprojectmar.git in his remote repo
15+
16+
> Make a clone of your forked repo on your local machine.
17+
18+
> In that clone, make changes, run tests, create commits etc.
19+
20+
> Push you changes to your forked repo (sonal04devops).
21+
22+
> Issue a pull request to sonal0409, and wait for her to review it.
23+
24+
25+
> sonal0409 merges your pull request; your work gets integrated into her GitHub repo.
26+
27+
Great!Your work was not in vain.
28+
To save space on GitHub's servers, and if you don't intend to contribute to sonal0409 repo any time soon, you can safely delete your fork.

0 commit comments

Comments
 (0)