computer_science:git:resources:git_cheatsheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
computer_science:git:resources:git_cheatsheet [2020/11/19 15:28] – created carlossousacomputer_science:git:resources:git_cheatsheet [2023/12/01 12:07] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +======  ======
 +
 ====== Git Cheatsheet ====== ====== Git Cheatsheet ======
  
-===== Delete All Commit History =====+===== Initialize & Add Remote Git =====
  
-  -+<code bash> 
 +git init 
 +git remote add origin <url> 
 +git fetch 
 +git branch --set-upstream-to=origin/<branch> master 
 +git pull 
 + 
 + 
 +</code> 
 + 
 +===== Push Changes to Remote Git ===== 
 + 
 +<code bash> 
 +# Add all changes to the commit 
 +git add . 
 +# Commit with Comment 
 +git commit -m "<comment>" 
 +git push 
 + 
 + 
 +</code> 
 + 
 +===== Delete All Commit History =====
  
-Checkout+<code bash> 
 +Checkout 
 +git checkout --orphan latest_branch
  
-''git checkout --orphan latest_branch'' +# Add all the files 
-  -+git add -A
  
-Add all the files+# Commit the changes 
 +git commit -am "commit message"
  
-''git add -A'' +# Delete the branch 
-  -+git branch -D master
  
-Commit the changes+# Rename the current branch to master 
 +git branch -m master
  
-''git commit -am "commit message"'' +# Finally, force update your repository 
-  -+git push -f origin master
  
-Delete the branch 
  
-''git branch -D master'' +</code>
-  -+
  
-Rename the current branch to master+===== Pushing new branch requires username / password =====
  
-''git branch -m master'' +<code bash> 
-  -+# Fix with 
 +git remote set-url origin git@github.com:<username>/<rep>.git
  
-Finally, force update your repository+# Push the branch 
 +git push origin <branch-name>
  
-''git push -f origin master''+</code>
  
  
  • computer_science/git/resources/git_cheatsheet.1605799735.txt.gz
  • Last modified: 2023/12/01 12:07
  • (external edit)