Cheat sheet for work with Git
Git is an indispensable tool for managing versions of code in development. It allows you to track changes in the project, return to previous versions and work effectively in a team, preventing code conflicts. With its help, developers can conduct parallel work on different functions using branches, and then combine them. In addition, Git provides reliable storage of the history of changes, which helps to quickly find and correct errors. Due to its popularity, many services, such as GitHub and GitLab, offer convenient platforms for collaboration and project management. In this note, I collected the commands that I use in my work
The cheat sheet on version control system – Git
to see commits
git log --pretty=oneline
to see remote URL repositories
git remote -v
to clone into a non-empty directory
git init git remote add origin https://name@bitbucket.org/name/rep.git git fetch git checkout -t origin/master
an event log
git reflog
to change a repository
git remote set-url origin https://some@bitbucket.org/some/some_st.git
new repository
git remote add origin https://some@bitbucket.org/some/test.git git push -u origin master
to delete a branch locally
git branch -d fix-protobaz
to delete a branch on the server
git push --delete origin fix-protobaz
to remove a file from the index
git rm --cached --ignore-unmatch path/file.js
to create a new branch
git branch some_branch
to create a new branch and immediately switch to it
git checkout -b some_branch
to switch to another branch
git checkout some_branch
to edit last commit comment
git commit --amend -m "new comment"
discard last commit but save changes
git reset HEAD~
delete last commit and delete changes
git reset --hard HEAD~
cancel the merge (for example, if you don’t want to resolve conflicts)
git merge --abort
renaming the local master branch to main
git branch -m master main
Similar posts:
-
Configuring HTTPS for Nginx
HTTPS stands for Hypertext Transfer Protocol Secure, and it is the secure version of HTTP, the protocol used for communication between your web browser and a website. HTT...
-
Protecting a Website or Directory with a Password Using .htaccess and .htpasswd
Securing a website or a specific directory with a password is a simple yet effective way to restrict access. This can be done using .htaccess and .htpasswd files in Apach...
-
How to Install and Delete XAMPP on Linux (Ubuntu)
XAMPP is a web development server build. This software is cross-platform, there are versions for Linux, Windows and Mac. The build includes Apache, PHP, MariaDB, phpMyAdm...
Leave a Reply