This skill explains how to use the Git command line for everyday development tasks in a repository.
Use this skill when:
git --version succeeds).
git init or git clone.
When uncertain, suggest the user run:
git status
to see whether the current folder is a Git repository.
git status, git diff, git log) before suggesting changing commands.
git reset --hard
git clean -fdx
git push --force
Check what has changed and whether there are untracked files:
git status
See detailed changes in the working tree:
git diff # unstaged changes
git diff --staged # staged (to-be-committed) changes
Stage a specific file:
git add path/to/file
Stage all tracked and untracked changes:
git add .
Unstage a file (keep changes in the working tree):
git restore --staged path/to/file
Create a commit with a message:
git commit -m "short, descriptive message"
If the user prefers a multi-line message, suggest:
git commit
which opens their editor.
Create and switch to a new branch:
git checkout -b feature/my-branch
Switch to an existing branch:
git checkout main
List local branches:
git branch
If the repository already has a remote (for example origin):
git fetch
git pull
git push -u origin <branch-name>
For subsequent pushes on the same branch:
git push
Clone an existing remote repository:
git clone <repo-url>
Initialize a new repository in the current folder:
git init
Optionally add a remote:
git remote add origin <repo-url>
When the user needs to temporarily put aside local changes:
git stash
List stashes:
git stash list
Apply and keep the top stash:
git stash apply
Apply and drop the top stash:
git stash pop
Show recent commits (compact format):
git log --oneline --decorate --graph --all
See who last changed each line of a file:
git blame path/to/file
git init (if appropriate), or
git clone .
git pull --rebase or git pull (depending on the team’s policy), then retry git push.
git add,
git commit or git rebase --continue.
共 1 个版本