使用git代码版本管理

Using git for version control

Tool
R
Python
Author

Tony D

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

reset to the last commit with commit id but keep your actual file unchange

git reset –soft HEAD~1

reset to the last commit with commit id

git reset –hard e4a59dd6b356b93f914db2a2a253dc55582bd61e