learn git :

learn git :

  • 1/Starting a Git Repository:

  • Configuring Git: Before you start working on Git, you have to configure your name and email by using git config.

  • Initializing a new repository: If you want to create a repository in an existing project use git init.

  • Cloning an existent repository: there are several possibilities to clone a repository, but the HTTP, git, and ssh protocols are used the most. If you want to clone type git clone.

  • Adding a file: If you want to add a file in your repository type git add MyFileName. But if you want to take all the files inside the current repository use add(.) just after git add.

  • Committing a file: The commit command is local to your own repository, nobody except you can see it. You can commit a file by typing git commit -m "description message". To commit everything use the following message git commit -m "my commit message".

  • Pushing a file: once committed, you can push the files to the remote repository. So just type the following command, git push remote repository. git.

  • Removing a file: There are two ways to remove a file delete the file and command the changes type this command line git commit -m 'delete this file. The second way is to delete the file only through git using the following command git rm --cached MyFileName.txt.

  • Checking the status: the is a way to show the working tree status only by typing git status.

  • Ignoring files: Git can ignore some files or folders from your working tree. If you want to do that, create a .gitignore file inside the root of your working tree. Then add this line in the file touch .gitignore.

  • Renaming or moving files: to rename or move a file type git mv file.txt.

  • Viewing the staged/unstaged changes: to show unstaged changes type git diff. But to show staged -changes use git diff --staged.

  • Viewing the history: To see the history type git log.

  • Viewing a commit: if you want to see the last commit just type git show Head.

  • 2/Summary: these steps help you to create a Git repository, how to put content in it, and how to push data to a remote repository.