User Tools

Site Tools


git

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git [2016/05/14 16:04] – external edit 127.0.0.1git [2023/08/18 18:15] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Git Cheat Sheet ====== ====== Git Cheat Sheet ======
  
 +These are the commands that I look up the most to make sure I'm doing them right. Eventually I'll remember them...
  
 ===== Branches ===== ===== Branches =====
  
-Delete a local branch+==== Create a new branch from current changes ==== 
 + 
 +This will create the new branch. When the branch is created, it will be active with the changes from the old branch. Switching back to the old branch will no longer show the changes. 
 + 
 +<code> 
 +$ git checkout -b <new branch> 
 +</code> 
 + 
 +==== Create upstream branch from local branch ==== 
 + 
 +Commit any local changes then: 
 + 
 +<code> 
 +$ git push -u origin <new branch> 
 +</code> 
 + 
 +==== Delete a local branch ==== 
 <code> <code>
 $ git branch -D <branchName> $ git branch -D <branchName>
Line 10: Line 28:
 </code> </code>
  
-Delete a remote branch+==== Delete a remote branch ==== 
 <code> <code>
 $ git push origin --delete <branchName> $ git push origin --delete <branchName>
Line 16: Line 35:
  - [deleted]         <branchName>  - [deleted]         <branchName>
 </code> </code>
 +
 +If someone already deleted the remote branch, synchronize your local branch list with:
 +
 +<code>
 +$ git fetch --prune
 +</code>
 +
 +==== Merge ====
 +
 +Merge branch into current branch
 +
 +<code>
 +$ git merge <branch>
 +</code>
 +
 +
git.1463241895.txt.gz · Last modified: 2023/08/18 18:15 (external edit)