-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit Commands.txt
More file actions
50 lines (43 loc) · 2.47 KB
/
Copy pathgit Commands.txt
File metadata and controls
50 lines (43 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
https://www.datacamp.com/tutorial/git-push-pull
git status
git add .
git status
git commit -m "Message"
git add remote add <origin> <url>
git push -u origin master/main
git branch -a
Initialization and Configuration:
git init: Initialize a new Git repository in the current directory.
git config --global user.name "Your Name": Set your global Git username.
git config --global user.email "your.email@example.com": Set your global Git email.
Basic Workflow:
git status: Show the current status of the repository (untracked, modified, staged).
git add <file>: Add a specific file to the staging area.
git add .: Add all modified and new files to the staging area.
git commit -m "Your commit message": Commit staged changes with a descriptive message.
git commit -am "Your commit message": Add all modified files and commit (skips git add step).
git log: Show the commit history.
Branching and Merging:
git branch: List all branches in the repository.
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 in one step.
git merge <branch_name>: Merge changes from one branch into the current branch.
Remote Repositories:
git remote add origin <remote_repository_URL>: Add a remote repository.
git push -u origin <branch_name>: Push commits to a remote repository for the first time.
git push: Push commits to a remote repository.
git pull: Fetch and merge changes from a remote repository into the current branch.
git clone <repository_URL>: Clone a remote repository to your local machine.
Undoing Changes:
git reset HEAD <file>: Unstage a file from the staging area.
git checkout -- <file>: Discard changes in a specific file.
git reset --soft HEAD~1: Undo the last commit and keep changes staged.
git reset --mixed HEAD~1: Undo the last commit and unstage changes.
git reset --hard HEAD~1: Undo the last commit and discard all changes.
Tagging:
git tag <tag_name>: Create a lightweight tag.
git tag -a <tag_name> -m "Tag message": Create an annotated tag with a message.
git push origin <tag_name>: Push a tag to a remote repository.
git tag -d <tag_name>: Delete a tag locally.
git push origin --delete <tag_name>: Delete a tag from a remote repository.