-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.html
More file actions
138 lines (130 loc) · 5.06 KB
/
Notes.html
File metadata and controls
138 lines (130 loc) · 5.06 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Git Stashing Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-black text-white p-6">
<div class="max-w-4xl mx-auto">
<h1 class="text-3xl font-bold border-b-2 border-white pb-2">
Git Stashing: Complete Notes
</h1>
<section class="mt-4">
<h2 class="text-2xl font-semibold">1️⃣ What is Git Stashing?</h2>
<p class="mt-2">
Git stashing temporarily saves uncommitted changes without committing
them. This allows you to switch branches or pull updates without
losing progress.
</p>
<p>
When you stash changes, Git stores them in a separate stack (stash
list), allowing you to reapply them later.
</p>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">2️⃣ Basic Stashing Commands</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>
<span class="font-bold">Stash current changes:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash</code>
</li>
<li>
<span class="font-bold">Stash untracked files:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash -u</code>
</li>
<li>
<span class="font-bold"
>Stash all (tracked + untracked + ignored):</span
>
<code class="bg-gray-800 px-2 py-1 rounded">git stash -a</code>
</li>
</ul>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">3️⃣ Viewing and Applying Stashes</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>
<span class="font-bold">List all stashes:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash list</code>
</li>
<li>
<span class="font-bold">Apply latest stash:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash apply</code>
</li>
<li>
<span class="font-bold">Apply and remove stash:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash pop</code>
</li>
</ul>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">4️⃣ Removing Stashes</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>
<span class="font-bold">Delete a specific stash:</span>
<code class="bg-gray-800 px-2 py-1 rounded"
>git stash drop stash@{0}</code
>
</li>
<li>
<span class="font-bold">Delete all stashes:</span>
<code class="bg-gray-800 px-2 py-1 rounded">git stash clear</code>
</li>
</ul>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">5️⃣ Advanced Stashing</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>
<span class="font-bold">Stash with a message:</span>
<code class="bg-gray-800 px-2 py-1 rounded"
>git stash push -m "Fix issue"</code
>
</li>
<li>
<span class="font-bold">Stash a specific file:</span>
<code class="bg-gray-800 px-2 py-1 rounded"
>git stash push -- index.html</code
>
</li>
<li>
<span class="font-bold">Create a new branch from stash:</span>
<code class="bg-gray-800 px-2 py-1 rounded"
>git stash branch new-branch stash@{0}</code
>
</li>
<li>
<span class="font-bold">Show stash details:</span>
<code class="bg-gray-800 px-2 py-1 rounded"
>git stash show stash@{0}</code
>
</li>
</ul>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">6️⃣ When to Use Git Stash?</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>✅ When you need to switch branches but don’t want to commit.</li>
<li>✅ Before pulling updates to prevent conflicts.</li>
<li>✅ When working on multiple tasks and need temporary storage.</li>
</ul>
</section>
<section class="mt-6">
<h2 class="text-2xl font-semibold">7️⃣ When NOT to Use Git Stash?</h2>
<ul class="list-disc pl-6 mt-2 space-y-2">
<li>❌ If you need long-term storage (use commits instead).</li>
<li>❌ If you need to share work (stash is local-only).</li>
<li>❌ If you stash too often and forget important changes.</li>
</ul>
<img src="git-stash.png" alt="" />
</section>
<footer class="mt-10 border-t border-white pt-4 text-center">
<p class="text-gray-400">
🔥 Made with ❤️ for Arman! Keep Learning, Keep Coding! 🚀
</p>
</footer>
</div>
</body>
</html>