website-creation

What is

Git

Git is a command line tool which is used for for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

The most comman commands in git

  • 1. git config --global user. name Abcd :give username
  • 2. git config --global user. Email abcd@email.com : give email
  • 3. git init : To initialize a git.
  • 4. ls -ltar : to get list of all files in your working directory.
  • 5. git status : Retrieve the current status of your git.
  • 6. git add -A : Used to add a file to staging area.
  • 7. git commit : used to commit the git.
  • 8. git commit -a -m "Doc" : used to commit a git with a message.
  • 9. git add -A : Used to add a file to staging area.
  • 10. git config --global user.name : to retrieve name of the user.
  • 11. git checkout abcd.html : this command is used to get the previously committed file if you by mistakenly deleted something
  • 12. git checkout -f: used to retrieve all file in the previous command.
  • 13. git log: It displays user date and time of commit.
  • 14. git log -p -5: last 5 in the previous case.
  • 15. git diff : it compares working directory with staging area.
  • 16. git diff --staged: compare with last commit status.
  • 17. touch a.html : create a file
  • 18. git rm a.html : delete a file from both staging area as well as commit level
  • 19. git rm --cached a.html : Remove a file from staging area.
  • 20. git status -s : Is used to check modified level in staging are and working tree
  • 21. touch .gitignore : To create a file to ignore the other files and folder which are not very useful and which consumes a lot of memory power. working procedure : you have to create this file and inside this you have to write the file name whish you want to ignore , eventually what it does is it ignore all the files which contains that name. If you you wrote /filename.log it ignore the file containing that name in his directory. If you wrote *.log this will ignore all folders containing git at the end.
  • 22. git branch : It is used to display the number of branches.
  • 23. git checkout branch1 : This command is used to switch between the branches.
  • 24. git merge feature : this should be run in main branch to verify you can use git log -p -2
  • 25. git checkout -b branch1 : It will create a new branch and take you to there without any extra command.
  • 26. git branch -d branch1 : used to delete branch.
  • If you find this post helpfull share with your friends.

    Thanks you.