Headsup to the Github Cheatsheet
This is part of GitHub/Git Tutorials and a continuation of the previous post where we discussed what is git and how to install it, I hope you have a basic understanding of what is Github in general. Let’s get started with Git Cheat Sheet. Git Cheat Sheet. 50 Git commands |Git Tutorials
Table Of Content
Git Setup
Git init
Git workflow
Selecting Files to Share
git add filename.ipynb
Commiting Changes
git commit -m "Give some meaningfull comments"
The Sharing Flow in Git
Adding a Remote
Git remote add origin URL
Uploading a file to Remote
git push origin [name_of_your_new_branch] -> Push the branch on github :
git push origin :[name_of_your_new_branch] -> Delete the branch on github :
Downloading File from the Remote
Git Pull -> To pull the file from the specific branch
Git branch -> to see the existing branch Git checkout main -> To switch between the branch
Git branch Meow -> This will create a new branch called Meow
Git branch -a -> To see all the branch you created.
Git Commands
Here are the 50 Git commands |Git Tutorials whch can help you with different tasks
#git config git --version git config --global #for global level config git config #for project level config git config --global user.name <"name"> git config --global user.email <"email"> git config --global core.editor <"editor"> git config --global color.ui true #basic git commands git init #Initialize a local Git repository git add . #add all file in the current directory git add #Add a file to the staging area git add -A #Add all new and changed files to the staging area git clone #Create a local copy of a remote repository #commit git git commit #commit staged files git commit -a #stage and commit all changes to tracked files git commit -am "message" #stage and commit all files with a message git commit --amend -m "message" #add additional info to last commit #view git log #view changes git log --summary #view changes detailed git log --oneline #view changes breifly git status git show #git diff command git diff git diff --color-words git diff -staged #to rename a file to directly stage git mv <filename> <renamed Filename> git rm <filename> #git branches git branch #list branches git branch <name> #create new branch git branch -d [branch name] #delete branch git checkout <branch name> #Switch to a branch git merge <branch name> #Merge a branch into the active branch git merge <source name> <Target name> #Merge a branch into a target branch #undo changes git checkout -- #telling git to undo changes in working directory. git checkout -- . #undo all changes in working directory git reset HEAD <file> #to unstage the file in staging area git revert <sha value> #to revert back to specfic commit git clean -n #show the untracked file status git clean -f #remove untracked files #adding our project to github git remote add origin <link URL> #Add a remote repository git branch -M main #make the branch main git push -u origin main #Push changes to remote repository (and remember the branch
FINAL VERDICT :
In conclusion, I hope you enjoyed reading this article on “Git Cheat Sheet. 50 Git commands |Git Tutorials”. In the next post, We will continue the Git/Github courses with more added materials. Signing off Sanjay Kv
Last Update:
April 18, 2021