Explain Basic Git Commands
$ git config --global user.name "AMD" $ git config --global user.email "email@example.com" $ git config --global credential.username "abdulmohammad11" // Name should be gir username -- This command for global config $ git config credential.username "abdulmohammad11" // Name should be gir username -- This command with in folder $ git config –list
this command shows the all configurated list
init command turn Dir into local Repo$ git init
Put and write some code/data inside the file and come out by$ git status
it’s in green color means added staging area
it’s in red color means not added yet staging area
Add command to add the created file to the staging area$ git add .
git commit$ git commit -m “first commit from git local” (m=message)
Now commit data from the staging area to the local repo
→ Store changes in the repository you will get one commit – ID
→ It has 40 alpha-numeric characters.
→ It uses SHA – 1 Checksum Concept.
→ Even if you change one dot, Commit – ID will get Change
→ It actually helps you to track the changes.
→ Commit is also named as SHA1 hash.
git log$ git log
to check what commits had done when and who did?
You will see commit Id like 12345678KD458F4lW3E4.Author, Mail id, Date, Time, message
git show$ git show <commit-id>
show command the content of commit ID
If we run the git commit command again it will show nothing to commit, working tree clean means data has been committed.
If want to send this code to my central repository, I have to connect the local repo to the central repo first, for this action I have to create a new repository (any name) and paste the URL of the git repo and execute a command as given below$ git remote add origin https://github.com/abdmohammad/gitLearing.git
Now local repo has been connected to the central repo, for Pulling data to the central repo, execute this command$ git pull -u origin master
you can execute without -u as well
Now you can see it has pulled all data/code from remote directory central repo, all details and commits has been done by other Machine,
Now local repo has been connected to the central repo, for pushing data to central repo execute this command$ git push -u origin master
push command local repo to central repo