Basic Git Commands

Bruce Lv.0 -10
Posted: 2022-12-27 03:14:03.143240, updated: 2022-12-27 05:13:06.723503, 191 reads

Here is a list of some basic Git commands to get you going with Git.

Git commands Notes
config git config --global user.name "Bruce Smith"
git config --global user.email bruce\@example.com
check out a repo git clone https://github.com/path/to/repo.git
Add files git add .
commit git commit -m 'commit message'
push git push origin main
switch branch git checkout branch_name
create a branch and checkout git checkout -b branch_name
update from remote repo git pull
merge from a branch into your current branch git merge branch_name
sync with upstream and rebase git pull upstream main --rebase
preview changes git diff
diff with two branches git diff source-branch target-branch
undo local changes git checkout -- file_name discard your local changes in this file and override with last content in head
discard all local changes git fetch origin
git reset --hard origin/main
remove files from index git rm file_name remove files from index and working directory
0  
Contributors: Bruce 100% ( 1 revisions )
Revision Date Edited by Changes Status
1 2022-12-27 05:13:06.723503 Bruce 156++ OK View
0 2022-12-27 03:14:03.141828 Bruce 913++ OK View
All contributions are licensed under Creative Commons, and note is collaboratively edited.
You are welcome to Contribute to this note.

Comments


Add a reply

Reply