Version control also known as source control is the ability to save changes made to files. when changes are made locally, they are committed and then send the repository within git. other developers can clone or pull and from the repository to get the update changes.
Here is a list of git basic commands to get you started.
- git config
Action: To set the username and email in the configuration file.Usage: To check your credentials enter the following commands
git config --global user.email
to set your email or username run the below commands
git config --global email="firstname.lastname@example.org"
git config --global username="my_username"
2. git init
Action: to initialize a git repository for a new or existing project.Usage: run the following command in the root of the directory of your project.
3. git clone
Action: Copy a git repository from a remote source.Usage: The following code will clone an existing project from the repository to the local directory.
git clone <git url>
4. git status
Action: To check the status of files you have made changes to.usage: List all files that have changed in your working directory.
5. git add
Action: Add changes to stage in your working directory usage: you can add a specific file by specifying the file name after this command, but it is better you use the below command to add every changed file in your working directory.
git add < file name>
or add everything in the current directory.
git add .
6. git commit
Action: Commit your changes and set it to a new commit object for your remote.
git commit -m "my first commit"
7. git push
Action: push your changes to the remote repository.if you have committed your changes then you should push them with the following command.
9. git pull
Action: pull the update changes from the remote repository.if your remote has updated changes pull them using the following command.
10 git branch
Action: Check your current branch
11 git branch -a
Action: list all available branch
git branch -a
12 git stash
Action: save changes that you do not want to commit immediately. git stash apply if you want to bring your save changes back
13 git merge
Action: merge two branches you were working on.
git merge <branch to merge>
13 git remote
Action: check what remote or source you have or add a new remote.