-
Notifications
You must be signed in to change notification settings - Fork 9
/
GIT-BASICS.rtf
178 lines (177 loc) · 5.09 KB
/
GIT-BASICS.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{\rtf1\ansi\ansicpg1252\cocoartf2761
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww34000\viewh21400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\fs24 \cf0 git-basics\
\
Repository Setup\
\
This repository is a step-by-step guide to setting up a new Git repository, creating and modifying files, committing changes, creating and merging branches, and pushing the changes to a remote repository on GitHub.\
\
Prerequisites\
\
Before you begin, you'll need to have the following installed on your system:\
- Git (https://git-scm.com/downloads)\
- A text editor or an IDE of your choice\
- A GitHub account (https://github.com)\
\
Getting Started\
1. Configure Git User Name and Email (if needed)\
\
Before running the `git push` command, you may need to configure your Git user name and email address using the following commands:\
\
git config --global user.name "Your Name"\
git config --global user.email "[email protected]"\
\
Replace "Your Name" and "[email protected]" with your actual name and email address.\
\
2. Create a New Repository on https://github.com\
\
macOS\
Create a new directory for the project (Locally in terminal)\
mkdir software_design\
cd software_design\
\
Initialize a new Git repository\
git init\
\
Create a new remote repository on GitHub\
(Open your web browser, navigate to GitHub, and create a new repository named "software_design")\
Copy the URL of the new repository (e.g., https://github.com/your_username/software_design.git)\
\
Connect the local repository to the remote repository\
git remote add origin https://github.com/your_username/software_design.git\
\
Windows\
\
Create a new directory for the project (Locally in terminal)\
mkdir software_design\
cd software_design\
\
Initialize a new Git repository\
git init\
\
Create a new remote repository on GitHub\
(Open your web browser, navigate to GitHub, and create a new repository named "software_design")\
Copy the URL of the new repository (e.g., https://github.com/your_username/software_design.git)\
\
Connect the local repository to the remote repository\
git remote add origin https://github.com/your_username/software_design.git\
\
3. Create and Upload File\
\
macOS\
\
Create a file named index.txt in your local repository\
printf "Hello, GitHub!" > index.txt\
\
Add the file to the staging area\
git add index.txt\
\
Commit the file with the message "First Commit"\
git commit -m "First Commit"\
\
Push the changes to the remote repository\
git push -u origin master\
OR\
git push -u origin main\
\
Windows\
\
Create a file named index.txt in your local repository\
echo "Hello, GitHub!" > index.txt\
\
Add the file to the staging area\
git add index.txt\
\
Commit the file with the message "First Commit"\
git commit -m "First Commit"\
\
Push the changes to the remote repository\
git push -u origin master\
OR\
git push -u origin main\
\
4. Make Changes and Commits\
\
Follow the same pattern for both macOS and Windows:\
\
Change 1\
For window: echo "Test written 1" > index.txt\
For macOS: printf "Test written 1" > index.txt\
git add index.txt\
git commit -m "Second Commit"\
git push\
\
Change 2\
For window: echo "Test written 2" > index.txt\
For macOS: printf "Test written 2" > index.txt\
git add index.txt\
git commit -m "Third Commit"\
git push\
\
Change 3\
For window: echo "Test written 3" > index.txt\
For macOS: printf "Test written 3" > index.txt\
git add index.txt\
git commit -m "Fourth Commit"\
git push\
\
Change 4\
For window: echo "Test written 4" > index.txt\
For macOS: printf "Test written 4" > index.txt\
git add index.txt\
git commit -m "Fifth Commit"\
git push\
\
Change 5\
For window: echo "Test written 5" > index.txt\
For macOS: printf "Test written 5" > index.txt\
git add index.txt\
git commit -m "Sixth Commit"\
git push\
\
5. Create and Merge Branch\
\
Follow the same pattern for both macOS and Windows:\
Create a new branch named 'Branch_1' from the main/master branch\
git branch Branch_1\
\
Switch to the 'Branch_1' branch\
git checkout Branch_1\
\
Modify index.txt in this branch\
echo "New branch test written 1" >> index.txt\
\
For macOS, use:\
printf "New branch test written 1\\n" >> index.txt\
\
git add index.txt\
git commit -m "Branch First Commit"\
git push origin Branch_1\
\
6. Merge Branch and Push Changes\
\
Follow the same pattern for both macOS and Windows:\
Switch back to the main/master branch\
git checkout master\
OR\
git checkout main\
\
Merge the changes from 'Branch_1' into the main/master branch\
git merge Branch_1\
\
Push the merged changes to the remote repository\
git push\
\
That's it! You've successfully set up a new Git repository, created and modified files, committed changes, created and merged branches, and pushed the changes to a remote repository on GitHub.\
\
Contributions\
\
Contributions to this repository are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.\
\
License\
\
This project is licensed under the [MIT License](LICENSE)}