├── Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a ├── 1.png ├── 2.png ├── Brainstorming_(1).jpg └── Untitled.png └── README.md /Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hassanelhllos2020/Git-GitHub-basics-summary/d169e9fa3ee8b41bd1874956a993cdd2ab96bc88/Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/1.png -------------------------------------------------------------------------------- /Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hassanelhllos2020/Git-GitHub-basics-summary/d169e9fa3ee8b41bd1874956a993cdd2ab96bc88/Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/2.png -------------------------------------------------------------------------------- /Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/Brainstorming_(1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hassanelhllos2020/Git-GitHub-basics-summary/d169e9fa3ee8b41bd1874956a993cdd2ab96bc88/Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/Brainstorming_(1).jpg -------------------------------------------------------------------------------- /Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/Untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hassanelhllos2020/Git-GitHub-basics-summary/d169e9fa3ee8b41bd1874956a993cdd2ab96bc88/Git & GitHub 9cdab09eeee14f4488bbc26d94d9a01a/Untitled.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git & GitHub 2 | 3 | # resources 4 | 5 | [AraBigData/Git/git.ipynb at main · ahmedsami76/AraBigData · GitHub](https://github.com/ahmedsami76/AraBigData/blob/main/Git/git.ipynb) 6 | 7 | [(1) Git and GitHub | شخبط وانت متطمن - YouTube](https://www.youtube.com/watch?v=Q6G-J54vgKc&t=9319s) 8 | 9 | [My progress - Git Exercises (fracz.com)](https://gitexercises.fracz.com/committer/71580966ec5aef994480cca3ac088af7ebf307e3?email=hassanelhllos@gmail.com) 10 | 11 | ## game 12 | 13 | [Learn Git Branching](https://learngitbranching.js.org/) 14 | 15 | [https://ohmygit.org/](https://ohmygit.org/) 16 | 17 | - Github desktop 18 | 19 | [https://youtu.be/8Dd7KRpKeaE?si=o6sZBBqHfjPCSO1g](https://youtu.be/8Dd7KRpKeaE?si=o6sZBBqHfjPCSO1g) 20 | 21 | 22 | ![Brainstorming (1).jpg](Git%20&%20GitHub%209cdab09eeee14f4488bbc26d94d9a01a/Brainstorming_(1).jpg) 23 | 24 | ## gitting started 25 | 26 | ```bash 27 | git config --global user.name "hassan elhllos" 28 | git config --global user.email"hassanelhllos@gmail.com" 29 | ----------- 30 | git init 31 | **delete ripo** 32 | $ rm -rf .git 33 | ``` 34 | 35 | ## querying configration 36 | 37 | ```bash 38 | git config --list 39 | ``` 40 | 41 | --- 42 | 43 | ## some important prompts 44 | 45 | ```bash 46 | clear 47 | ls | ls -al // show files in current folder 48 | pwd #to see which path you are currently in 49 | cd # to open folder 50 | cd .. # back 51 | cd /f #open partition 52 | cd 'programing languages' # use '' on multible words folder 53 | ---- 54 | mkdir gitwork # creates folder 55 | echo "hello , git" >> file.txt # creates txt file 56 | cat file.txt # shows file content 57 | ``` 58 | 59 | ## set Git repo 60 | 61 | ```bash 62 | git init #Initialized empty Git repository 63 | git status 64 | git ls-files # show files in **index 65 | git ls-files -s # show sha1 of files** 66 | find .git/objects/ -type f # show files in **repo** 67 | ``` 68 | 69 | ## index and repo prompts (we are in index now) 70 | 71 | ```bash 72 | git add file.text | * # add file to index (staging) 73 | git rm --cached # udno (staging) 74 | git restore file.txt 75 | ------- 76 | git cat-file -p "file-sha" # shows file content >> **git ls-files -s** 77 | git cat-file -t "file-sha" # shows file type 78 | git cat-file -s "file-sha" # shows file size 79 | ``` 80 | 81 | ![Untitled](Git%20&%20GitHub%209cdab09eeee14f4488bbc26d94d9a01a/Untitled.png) 82 | 83 | ## commit & Log 84 | 85 | ```bash 86 | #https://www.atatus.com/blog/tracking-code-changes-with-git-log/#introduction-to-git-log 87 | $ git commit -m "intial commit" #commit file to repo 88 | $ git commit -am "" #Skipping the Staging Area 89 | git log #history 90 | $ git log -n 3 #number of commits 3 91 | $ git log --oneline 92 | git log --graph 93 | $ git log file.txt #show log for specific file 94 | $ git log --oneline file.txt 95 | ------------------------------- 96 | find .git/objects/ -type f #show files in **repo 97 | $ git cat-file -p ("sha") #read the commit file , i get sha from (**git log**) 98 | ------------------------------ 99 | git diff // diffrence between tree and index 100 | git diff SHA1..head //diffrence between two commits 101 | $ git diff --staged // diffrence between index and repo 102 | $ git show 789cde6** 103 | ``` 104 | 105 | ## remove and undo 106 | 107 | ```bash 108 | $ git rm file.txt #removes file from tracking(index) and from filesystem 109 | $ git restore file.txt #REVERTING IT FROM THE LAST index (staged) 110 | $ git restore --staged file.txt #REVERTING IT FROM THE LAST stage 111 | ------------------------ 112 | $ git add 113 | $ git rm --cached # Untracking tracked file 114 | ------------------------ 115 | $ git commit --amend #edit last commit message 116 | ``` 117 | 118 | ## #move head in commits 119 | 120 | ```bash 121 | $ git reflog #show head moves 122 | $ git reset head~1 #git back to any commit i want 123 | $ git reset head@{1} #git forward to any commit 124 | #the commit i reset are stored in the index , so i need to do $git restore . 125 | #to skip this step just add --hard 126 | $ git reset head@{1} --hard #restore last commit directly 127 | ---------------------------------------------- 128 | git checkout main^ #git back to "the first parent of main". 129 | git branch -f main HEAD~3 #moves (by force)the main branch to three parents behind HEAD. 130 | ``` 131 | 132 | ### important concept “detching” 133 | 134 | ![1.PNG](Git%20&%20GitHub%209cdab09eeee14f4488bbc26d94d9a01a/1.png) 135 | 136 | ![2.PNG](Git%20&%20GitHub%209cdab09eeee14f4488bbc26d94d9a01a/2.png) 137 | 138 | ## Taging 139 | 140 | ```bash 141 | $ git tag -a -m "" 142 | $git show v2.0 143 | ``` 144 | 145 | ## alias 146 | 147 | ```bash 148 | $ alias logs="git log --oneline --all --graph --decorate" 149 | ``` 150 | 151 | ## Branching 152 | 153 | ```bash 154 | $git branch <"name"> #create branch 155 | $git branch -m "main" #rename branch 156 | $git branch -v #show branch list 157 | $git switch teting #switch brtween branches || $git checkout 158 | $git checkout -b [yourbranchname] #create branch and switch to it at same time 159 | $git merge <"name of branch i'm merging into master"? #i'm in master branch 160 | $Git Rebase #like merge but make a linear sequence and much cleaner 161 | $git branch --merged #show branches that had merged into master 162 | $git branch -d <"name"> #delete branch 163 | ``` 164 | 165 | --- 166 | 167 | # **remote** 168 | 169 | ## clone 170 | 171 | ```bash 172 | $git clone <"path"> <"name"> 173 | $git remote -v #show remote details 174 | $git fetch origin #pull updates from remote - requiers $git merge 175 | $ git pull origin #fetch and merge in one step 176 | 177 | $git push -u origin <"my current branch"> #update the remote 178 | ------------------- 179 | **#to push into remote i should be in deffrent branch before pushing** 180 | $git push --all #Push all of your local branches to the specified remote. 181 | 182 | ``` 183 | 184 | --- 185 | 186 | ### astrics 187 | 188 | ```bash 189 | $rm *hassan # remove any thing end with hassan 190 | ``` 191 | 192 | --- 193 | 194 | # GitHub 195 | 196 | ## github https 197 | 198 | after creating empty repo 199 | 200 | ```bash 201 | echo "# newrep" >> README.md 202 | git init 203 | git add README.md 204 | git commit -m "first commit" 205 | git branch -M main #change branch master name to main 206 | git remote add origin https://github.com/hassanelhllos2020/newrep.git 207 | $ git remote rename origin dest #Change remote name from 'origin' to 'desti' 208 | $ git remote rm destination #remove remote 209 | git push -u origin main 210 | 211 | ``` 212 | 213 | ## ssh 214 | 215 | [https://github.com/settings/keys](https://github.com/settings/keys) 216 | 217 | [Generating a new SSH key and adding it to the ssh-agent - GitHub Docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) 218 | 219 | --- 220 | 221 | 1- one the local git 222 | 223 | 224 | 225 | ```bash 226 | ssh-keygen -t ed25519 -C "hassanelhllos@.com" 227 | ``` 228 | 229 | 2- after runnig this code and hit enter 3 times, 230 | 231 | > **it creates two files** 232 | > 233 | > 234 | > Your identification has been saved in /c/Users/HASSA/.ssh/id_ed25519 235 | > Your public key has been saved in /c/Users/HASSA/.ssh/id_ed25519.pub 236 | > 237 | 238 | 3- show the public key 239 | 240 | ```bash 241 | $cat ~/.ssh/id_ed25519.pub 242 | ``` 243 | 244 | 4- add shh key from github setting 245 | 246 | 5- on bash 247 | 248 | ```bash 249 | $ git remote add origin git@github.com:hassanelhllos2020/newrep.git 250 | ``` 251 | 252 | --- 253 | 254 | ## how to contribute 255 | 256 | 1- do a fork to the repo 257 | 258 | 2- clone the forked repo , and add remote the original repo 259 | 260 | 3- do edits and push to my forked repo 261 | 262 | 4- pull request 263 | --------------------------------------------------------------------------------