Skip to content

Instantly share code, notes, and snippets.

@jalal246
Last active January 27, 2020 15:13
Show Gist options
  • Select an option

  • Save jalal246/62fb269cefc90420217c7ea0cef0d578 to your computer and use it in GitHub Desktop.

Select an option

Save jalal246/62fb269cefc90420217c7ea0cef0d578 to your computer and use it in GitHub Desktop.
Most Common Git Instructions
# Renaming Git Branch
git checkout <old_name> # Swhitch to the local branch you want to rename
git branch -m <new_name> # Rename it
git push origin --delete <old_name> # Delete the <old_name> remote branch
git push origin -u <new_name> # Push the <new_name>
# Pull from master into the development branch
git checkout dev # gets you on branch development
git fetch origin # gets you up to date with origin
git merge origin/master
# Move or Rename file and keep tracks of changes:
git mv old-file-name.js new-file-name.js
# Undo
git reset <file> # Undo git add before commit
git reset # To Unstage all:
# Create the branch on your local machine and switch in this branch :
git checkout -b [develop] # Change working branch to new one
git checkout -b [feat1] [develop] # Create another branch not from master:
git push --set-upstream origin [name_of_your_new_branch] # Push the branch on github :
# Merge branches to each other (feat1 to develop)
git checkout develop # Switch to develp
git pull # Pull changes
git checkout feat1 # Switch to feat1
git rebase develop # Rebase
# see all branches
git branch
# Rename branch
git branch -m feat1 feat_new
#################################################################################################
# Add a new remote branch for your branch :
git remote add [name_of_your_remote] [name_of_your_new_branch]
# Push changes from your commit into your branch :
git push [name_of_your_new_remote] [url]
# Update your branch when the original branch from official repository has been updated :
git fetch [name_of_your_remote]
# Merge changes, if your branch is derivated from develop you need to do:
git merge [name_of_your_remote]/develop
#################################################################################################
# Delete branch
git branch -d [name_of_your_new_branch] # Delete a branch on your local filesystem :
git branch -D [name_of_your_new_branch] # To force the deletion of local branch on your filesystem :
git push origin :[name_of_your_new_branch] # Delete the branch on github :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment