-
Notifications
You must be signed in to change notification settings - Fork 5
1.2 Git Cheat Sheet
Majd Khalife edited this page Aug 31, 2024
·
5 revisions
-
git init: Create a new Git repository in the current directory.
-
git clone <repository_url>: Clone a remote repository to your local machine.
-
git status: Show the status of your working directory. -
git log: Displays a chronological list of commits, including their messages and unique identifiers.
-
git add <file>: Stage a changed file for commit. -
git add -A: Stage all changes.
-
git commit -m "Commit message": Create a new commit with staged changes.
-
git branch: List all branches. -
git branch -d <branch_name>: Delete a local branch that has been merged. -
git branch -r: List all remote branches -
git branch <branch_name>: Create a new branch. -
git checkout <branch_name>: Switch to a different branch. -
git checkout -b <branch_name>: Create and switch to a new branch.
-
git merge <branch_name>: Merge changes from one branch into the current branch.
-
git reset <file>: Unstage changes. -
git reset --soft <commit>: Reset to a previous commit, keeping changes staged. -
git reset --hard <commit>: Reset to a previous commit, discarding all changes. -
git revert <commit>: Create a new commit that undoes a previous commit.
-
git fetch --prune: Fetch changes from a remote and remove deleted branches from your local.
-
git push origin <branch_name>: Push a new branch to a remote repository.
-
git pull: Fetch and merge commits from the remote, only applies to the branch you are currently on. -
git push: Push commits made locally to the remote, so they can be seen by others on the same branch.
- The
.gitignorefile is used to specify files and directories to be ignored in commits.