Basic Git commands
Git is a distributed version control system used for tracking changes in files and is a fast process.Where we link our local repository and Github repository write code and commit into Github repo.
To Initialize a git repository:
ubuntu@ip-172-31-2-75:~/dir3$ git init hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty Git repository in /home/ubuntu/dir3/.git/
To link local and GitHub repo:
ubuntu@ip-172-31-2-75:~/dir3$ git remote add origin <repository url>
To clone GitHub repository URL:
ubuntu@ip-172-31-2-75:~/dir3$ git clone <URL>
To add file to staging area:
ubuntu@ip-172-31-2-75:~/dir3$ git add .
To commit changes from staging area to repository:
ubuntu@ip-172-31-2-75:~/dir3$ git commit -m "commit message"
To check the status of repository:
ubuntu@ip-172-31-2-75:~/dir3$ git status
To push code into GitHub repo:
ubuntu@ip-172-31-2-75:~/dir3$ git push -u origin master
To pull code from GitHub:
ubuntu@ip-172-31-2-75:~/dir3$ git pull
To check who has committed:
ubuntu@ip-172-31-2-75:~/dir3$ git log
to see what code is committed:
ubuntu@ip-172-31-2-75:~/dir3$ git show