forked from RitikSky-lab/the_data_echo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_command.sh
More file actions
235 lines (123 loc) · 4.91 KB
/
git_command.sh
File metadata and controls
235 lines (123 loc) · 4.91 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
##############################################################################
############################## GIT COMMAND GUIDE #############################
##############################################################################
# Exit immediately if any command fails
set -e
##############################################################################
# 1. INITIAL SETUP (RUN ONLY ONCE)
##############################################################################
# Set your Git username
git config --global user.name "Ritik"
# Set your Git email
git config --global user.email "[your-email@example.com](mailto:your-email@example.com)"
# Check Git configuration
git config --list
##############################################################################
# 2. CLONE REPOSITORY
##############################################################################
# Clone a repository from GitHub
git clone https://github.com/username/repo.git
# Move into project directory
cd repo
##############################################################################
# 3. CHECK STATUS & HISTORY
##############################################################################
# Check current status of files
git status
# View commit history
git log --oneline
##############################################################################
# 4. CREATE AND SWITCH BRANCH
##############################################################################
# Create a new branch and switch to it
git checkout -b feature-xyz
# Switch to existing branch
git checkout main
##############################################################################
# 5. ADD, COMMIT, PUSH CHANGES
##############################################################################
# Add all changed files
git add .
# Add specific file
git add filename.py
# Commit changes with message
git commit -m "Add new feature or fix bug"
# Push branch to remote repository
git push origin feature-xyz
##############################################################################
# 6. PULL LATEST CHANGES
##############################################################################
# Get latest changes from remote
git pull origin main
##############################################################################
# 7. MERGE BRANCH (LOCAL MERGE)
##############################################################################
# Switch to main branch
git checkout main
# Merge feature branch into main
git merge feature-xyz
# Push updated main branch
git push origin main
##############################################################################
# 8. DELETE BRANCH
##############################################################################
# Delete local branch
git branch -d feature-xyz
# Delete remote branch
git push origin --delete feature-xyz
##############################################################################
# 9. REMOTE MANAGEMENT
##############################################################################
# Check remote repositories
git remote -v
# Add upstream (original repo)
git remote add upstream https://github.com/original/repo.git
# Fetch upstream changes
git fetch upstream
# Merge upstream changes into main
git merge upstream/main
##############################################################################
# 10. STASH (SAVE TEMP WORK)
##############################################################################
# Save uncommitted changes
git stash
# Apply last stash
git stash apply
# List all stashes
git stash list
##############################################################################
# 11. GITHUB CLI (ISSUE MANAGEMENT)
##############################################################################
# Install GitHub CLI (if not installed)
sudo apt install gh
# Authenticate GitHub CLI
gh auth login
# Set default repository (important)
gh repo set-default username/repo
# Create a new issue
gh issue create
--title "Issue title"
--body "Describe the problem or feature request"
# List all issues
gh issue list
# View a specific issue
gh issue view 1
# Close an issue
gh issue close 1
##############################################################################
# 12. GITHUB CLI (PULL REQUEST AND BRANCH MANAGEMENT)
##############################################################################
gh pr create \
--base main \
--head Ritik574-coder:feature-xyz \
--title "Add setup script for data engineering environment" \
--body "Added fully commented setup_commands.sh for Docker, Python, and Java setup."
git checkout feature-xyz # switch to correct branch
git pull origin feature-xyz # latest le lo
# ab changes lao main se
git merge main
git push origin feature-xyz
##############################################################################
# END OF GIT + GITHUB COMMANDS
##############################################################################