Here are some basic Git commands with illustrative examples:
1. git init
Initialize a new Git repository in the current directory.
Example:
2. git clone <repository>
Clone a repository from a remote repository to your local machine.
Example:
3. git add
<file>
Add a file to the staging area to prepare for committing.
Example:
4. git commit -m
"<message>"
Create a new commit with a <message> to record changes in the staging area.
Example:
5. git status
Display the status of the repository and files, including the status of uncommitted changes.
Example:
6. git log
Display the commit history of the repository, including information about the commits, authors, and timestamps.
Example:
7. git pull
Synchronize and pull changes from a remote repository into your local repository.
Example:
8. git push
Push changes from your local repository to a remote repository.
Example:
9. git branch
Display the list of branches in the repository and the currently active branch.
Example:
10. git checkout <branch>
Switch to a different branch in the repository.
Example:
11. git merge <branch>
Merge changes from a branch into the current branch.
Example:
12. git remote add <name> <url>
Link a local repository with a remote repository by adding a remote.
Example:
13. git remote -v
Display the list of remotes linked to the local repository.
Example:
14. git reset <file>
Undo uncommitted changes in a specific file.
Example:
15. git stash
Temporarily stash uncommitted changes to work on a different branch.
Example:
These are just some of the basic Git commands. Git provides many more commands and functionalities for source code management and collaboration.