View on Notion
Git is a version control system that allows developers to collaborate on projects and keep track of changes. GitHub is a hosting platform for version control and collaboration on projects.echo "<Text>" >> README.md # create your first file in the repo
git init
git add README.md
git commit -m "<commit message>"
git branch -M main
git remote add origin <repo_url>
git push -u origin main
git remote add origin >repo_url>
git branch -M main
git push -u origin main
Git has many commands available to help you manage your projects. Some of the most common commands are:
git init
: Creates an empty Git repository in the current foldergit clone <url>
: Clones a remote repository to your computergit add <file>
: Adds a file to the staging areagit commit -m "<message>"
: Commits the changes to the repository with a messagegit push
: Pushes the changes to a remote repositorygit pull
: Pulls changes from a remote repository
Branches are used to work on different versions of a project simultaneously. You can create, delete, and merge branches as needed. Common branch commands include:
git branch <name>
: Creates a new branch with the given namegit checkout <name>
: Switches to the branch with the given namegit merge <name>
: Merges the branch with the given name into the current branchgit branch -d <name>
: Deletes the branch with the given name
Submodules allow you to include other Git repositories inside your own repository. This is useful for managing dependencies and keeping track of external changes.
git submodule add <url>
: Adds a submodule from the given urlgit submodule init
: Initializes the submodulesgit submodule update
: Updates the submodules to their latest versiongit submodule status
: Shows the status of the submodules