-
git init
this command initializes the repository.
git init
-
git add
this command adds file/files to the repository.
git add file_name.ext
or add all files in one go:git add .
,git add --all
-
git commit
this command commits the changes to the repository with a message.
git commit -m "message"
-
git clone
this command clones a repository which is stored in a cloud (e.g: github) and creates a local copy.
git clone url_for_repository
-
git push
this command pushes the local repository to the cloud(e.g: github).
git push
,git push -u remote_name branch_name
-
git pull
this command pulls or gets an changes from the copy of cloud-stored repository.
git pull
-
git branch
this command creates/deletes a branch.
Create:git branch branch_name
Delete:git branch -d branch_name
-
git rm
this command is used to delete file/files from git repository.
git rm --cached file_name.ext
,git rm --cached .
-
git status
this command is used to show changes to the git repository(new files, modified files, deleted files).
git status
-
git log
this command is used to show all commits.
git log
-
git checkout
this command is used to switch between branches.
git switch branch_name
-
git merge
this command is used to merge tow branches.
git merge target_branch source_branch
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (14)
Here are more practical ones(IMHO):
Change the last commit message
git commit --amend
Revert last unpushed commit
git reset HEAD~1 --soft
Show log one line
git log --oneline
Press q to exit
Delete a local branch
git branch -d <BRANCH NAME>
Ignore push and merge status and force delete:
git branch -D <BRANCH NAME>
Delete a remote branch
git push <REPOSITORY REF> --delete <BRANCH NAME>
example:
git push origin --delete beta-1.0.0
If branch ref is equal to a tag ref:
git push <REPOSTIORY REF> :refs/heads/<BRANCH NAME>
example:
git push origin :refs/heads/beta-1.0.0
And
git checkout -b <new-branch-name>
ty!
And
git log --all --graph --oneline
git status -s
Great list, if I was to add one:
git cherry-pick [commit id here]
incredibly useful to pick specific commits when you don't want the branch.It is always better to use
git checkout [commit id here || branch name] [filename of other branch]
than cherry pickNot always better. They work differently:
cherry-pick
will append the specified commit to the current one.checkout
will bring the specified commit's changes to the working directory (it's up to you to commit those changes).It really depends on what you want to do. I use both frequently.
thank you
git remote add <remote-name> <remote-url>
Add remote to project
git remote rename <old-remote-name> <new-remote-name>
Rename project remote
git remote rm <remote-name>
Delete remote from project
Something related to
git remote
which helps in changing the existing remote URL for a remote.Yes, forgot this one
Thank you very much 🙏
great
I find this extremely useful a lot of times
git reflog
Shows the history of the local HEAD. Useful when you lost some local code recently
I must sincerely say that I find this write up helpful. Thank you all