使用git代码版本管理

Using git for version control

Tool
R
Python
Author

Tony Duan

Published

March 25, 2025

download github desktop

https://desktop.github.com/download/

set up github account

https://github.com/

Clone a repository into a new directory

git clone

Initialize a new Git repository

git init

Add to the staging area

git add git add .

Commit changes to the repository

git commit -m “commit message”

View the commit history

git log

Check the status of changes

git status

Show the changes in the working directory

git diff

Create a new branch

git branch

List all branches

git branch

Switch to a different branch

git checkout

Create and switch to a new branch

git checkout -b

Merge a branch into the current branch

git merge

changes from a remote repository

git pull

Push changes to a remote repository

git push

Delete a branch

git branch -d git push origin –delete

Stash changes

git stash

Apply stashed changes

git stash apply

Show stashed changes

git stash list

Remove a file from the staging area

git reset

Undo the last commit

git reset –soft HEAD~1 git reset –hard HEAD~1