Git Commmands¶
Setting Up a Repository¶
-
Initialize a new Git repository:
-
Clone an existing repository:
Basic Workflow¶
-
Check the status of your repository:
-
Add changes to the staging area:
-
Commit changes:
Branching and Merging¶
-
Create a new branch:
-
Switch to a different branch:
-
Create and switch to a new branch:
-
Merge a branch into the current branch:
Remote Repositories¶
-
Add a remote repository:
-
Set the remote URL with a token (as per your example):
-
Push changes to a remote repository:
-
Pull changes from a remote repository:
-
Fetch changes from a remote repository (without merging):
Viewing History¶
-
View commit history:
-
View a summarized commit history (one line per commit):
Undoing Changes¶
-
Unstage a file:
-
Revert changes in a file to the last committed state:
-
Revert a specific commit:
Stashing Changes¶
-
Stash changes:
-
List stashed changes:
-
Apply stashed changes:
Working with Tags¶
-
Create a new tag:
-
Push tags to the remote repository:
Example Workflow¶
Let's go through a typical workflow using some of these commands:
-
Clone a repository:
-
Create a new branch:
-
Make changes to files and add them to the staging area:
-
Commit your changes:
-
Push your changes to the remote repository:
-
Switch back to the main branch:
-
Merge the new feature branch into the main branch:
-
Push the updated main branch to the remote repository:
This workflow demonstrates how to clone a repository, create and switch branches, make and commit changes, and push those changes to a remote repository.