Skip to content

Commit a933372

Browse files
committed
2 parents 2baadc0 + 90c829a commit a933372

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
<b>GitHub Branching Commands</b>
2+
# Github Basics<br><br>
3+
4+
## GitHub Branching Commands
35

46
<b>Create Branch:</b> ```git branch <new-branch-name>``` </br>
57
<b>View all branches:</b> ```git branch -a``` </br>
@@ -34,6 +36,7 @@
3436

3537
<b>Show commit history:</b> ```git log --oneline``
3638

39+
## Rebasing and Merging
3740
<b><ins>Incorporate your feature branch changes into development</ins></b> <br/>
3841
1.) ```git pull development```<br/>
3942
2.) ```git branch feature-branch```<br/>
@@ -50,24 +53,51 @@
5053
13.) ```git push -f``` (push integrated development changes to your remote feature branch)<br/>
5154

5255
<b>Merge or Rebase your features back into development</b><br/>
53-
14.) ```git checkout development``` (merge the updated code back into development<br/>
54-
15.) ```git merge/rebase feature-branch```<br/>
56+
14.) ```git checkout development```<br/>
57+
15.) ```git merge/rebase feature-branch``` (merge the updated code back into development) <br/>
5558
16.) ```git push```<br/>
5659

5760
14 - 16 can also be done via GitHub via Pull request to review changes before the merge
5861

59-
6062
<b><ins>How to Abort the rebase and restore the branch to its original state.</ins></b> <br>
6163
```git rebase --abort``` <br>
6264

65+
66+
## Stash
67+
68+
<b>Stash:</b> Temporarily save your changes without committing them to a branch<br>
69+
70+
<b>Commands: </b><br>
71+
- ```git stash``` -> save changes without committing them to a branch <br>
72+
- ```git stash save "Your stash message here"``` -> save changes with a message<br>
73+
- ```git stash list``` -> list all stashes <br>
74+
- ```git stash apply``` -> Reapply the most recent stash <br>
75+
- ```git stash apply stash@{n}```-> Reapply a specific stash from list <br>
76+
- ```git stash drop``` -> Remove latest stash<br>
77+
- ```git stash drop stash@{n}``` -> Remove specific stash from list<br>
78+
- ```git stash clear``` -> clear all stashes<br>
79+
- ```git stash branch <branch-name>``` -> Create a new branch from a stash<br>
80+
81+
82+
<b><ins>You have uncommitted changes in a local branch and want to switch to another branch without passing over those changes</ins></b> <br>
83+
Step 1: You are on `branch-A` with uncommitted changes<br>
84+
```git stash``` # Save changes and clean the working directory<br>
85+
```git checkout branch-B``` # Switch to another branch (e.g., branch-B)<br>
86+
87+
Step 2: Work on `branch-B` and then return to `branch-A` <br>
88+
```git checkout branch-A``` # Switch back to the original branch<br>
89+
```git stash apply``` # Restore the stashed changes on `branch-A`<br>
90+
91+
92+
6393
<b>Fetch the branch branch_name from the remote (origin) and creates a corresponding local branch with the same name.</b> <br>
6494
```git fetch origin branch_name:branch_name```<br><br>
6595

6696
<b><ins>Your remote branch has been rebased and you want changes from rebased remote branch on your local</ins></b> <br>
6797
1.) `git fetch origin` - Updates your local information about the remote branches without changing your working branch <br>
6898
2.) `git reset --hard origin/your-branch-name` - `Forces your local branch to match the remote branch exactly, discarding any local changes or commits that differ from the remote branch`
6999

70-
<b><ins>Troubleshooting Git</ins></b> <br/>
100+
## Troubleshooting Git</ins></b><br>
71101

72102
<b>Issue #1</b><br>
73103
After performing <b>git pull</b> you get this error:
@@ -77,9 +107,14 @@ After performing <b>git pull</b> you get this error:
77107

78108
<b>Issue #2</b><br/>
79109
After performing a ```git push -f``` or ```git push -u origin your-feature-branch``` you get this:<br>
80-
```the upstream branch of your current branch does not match the name of your current branch```<br><br>
81-
<b>Solution:</b> <br>
110+
111+
```
112+
the upstream branch of your current branch does not match the name of your current branch
113+
```
114+
115+
<b>Explaination:</b> <br>
82116
Your local and remote branch have different names<br><br>
117+
83118
<b>2 possible solutions</b><br>
84119
1.) rename your <b>local branch</b> to same name as <b>remote branch</b><br/>
85120
2.) delete the <b>remote branch</b> and push again

0 commit comments

Comments
 (0)