/git

Frequently used git commands

Primary LanguageBatchfile

Basic Git commands

Create a new repository on the command line

  • echo "# my-dream-app" >> README.md
  • git init
  • git add README.md
  • git commit -m "first commit"
  • git branch -M main
  • git remote add origin https://github.com/SahebRana/my-dream-app.git
  • git push -u origin main

push an existing repository from the command line

  • git remote add origin https://github.com/SahebRana/my-dream-app.git
  • git branch -M main
  • git push -u origin main

Known commands:

	1.	git init
	
	2.	git add: git add file_name.extention, 
	
	3.	git commit: git commit -m "Message", 
	
	4.	git diff
	
	5.	git log: git log, git log file-name,
	
    6.  git show: git show log-hash
    
    7.  git checkout: git checkout log-hash, git checkout master, git checkout master –f (for a single file)
    
    8.  git reflog
    
    9.  git reset: git reset –soft log-hash, git reset –hard log-hash, git reset HEAD@{n}, git reset hard
    
    10. git pull
    
    11. git push
    
    12. git merge
    
    13. git stash