Here are some simple git commands that helped me to get started with git and github.
git --version: This is used to check the version of git currently installed.
git init: This is used to turn a directory into an empty git repository.
git add "file_name": This is used to add a file to a git index. The files need to be added here before they can be committed to a git repository. To add all the files in a directory, use "git add ."
git commit -m "commit_message": This is used to record all the changes made to the files in a local repository.
git status: This returns the current status of a git repository, i.e. the current working branch and whether or not there are any changes to commit to it.
git config: This is used to assign some of the settings and configurations on Git, two of which include user.name and user.email. It is used as thus:
git config user.name "Tripp007"
git config user.email "tripp007@gmail.com"
This assigns the username and email respectively.git branch branch_name: This is used to create a new branch of development. Changes are made on individual branches before implementing them unto the main branch after a thorough review.
git branch: This returns a list of all the branches in the repository.
git checkout branch_name: This switches the user from the current branch to the specified branch.
git merge branch_name: This merges the specified branch to the main branch.
git branch -d branch_name: This deletes the specified branch.
git remote add origin git_repository_link: This is used to connect to a remote repository.
git clone git_repository_link: This downloads a copy of the remote git repository into the directory that is currently opened in the terminal.
git pull origin main: This is used to pull all the changes made in the remote repository into the local one. It must be done after the remote repository has been connected.
git push origin main: This is used to push all the changes made in the local repository into the remote one.
These are the ones that I found the most useful. If I made any mistakes, please notify me and I will make the correction. Thank you for reading.
Top comments (0)