- Clone a repository
- Create a branch
- Stage, commit, and push changes
- Stash changes
- Add files to a branch
- Merge requests
- Related topics
Basic Git operations
Basic Git operations help you to manage your Git repositories and to make changes to your code. They provide you with the following benefits:
- Version control: Maintain a history of your project to track changes and revert to previous versions if needed.
- Collaboration: Enable collaboration and makes it easier to share code and work simultaneously.
- Organization: Use branches and merge requests to organize and manage your work.
- Code quality: Facilitates code reviews through merge requests, and helps to maintain code quality and consistency.
- Backup and recovery: Push changes to remote repositories to ensure your work is backed up and recoverable.
To use Git operations effectively, it’s important to understand key concepts such as repositories, branches, commits, and merge requests. For more information, see Get started learning Git.
To learn more about commonly used Git commands, see Git commands.
Clone a repository
The git clone
command creates a copy of a remote repository on your computer. You can work on the code locally
and push changes back to the remote repository. For more information, see Clone a Git repository.
Create a branch
The git checkout -b <name-of-branch>
command creates a new branch in your repository. A branch is a copy of the
files in your repository that you can modify without affecting the default branch.
For more information, see Create a branch.
Stage, commit, and push changes
The git add
, git commit
, and git push
commands update your remote repository with your changes.
Git tracks the changes against the most recent version of the checked out branch.
For more information, see Stage, commit, and push changes.
Stash changes
The git stash
command temporarily saves changes that you don’t want to commit immediately.
You can switch branches or perform other operations without committing incomplete changes.
For more information, see Stash changes.
Add files to a branch
The git add <filename>
command adds files to a Git repository or a branch.
You an add new files, modify existing files, or delete files.
For more information, see Add files to a branch.
Merge requests
A merge request is a request to merge changes from one branch into another branch. Merge requests provide a way to collaborate and review code changes. For more information, see Merge requests.