The following is a git checkout usage to switch to an existing branch: git checkout branch_name This command lets you switch between branches and restore files from different commits. To rename a Git branch, enter this command: git branch -m branch-name new-branch-name To create a Git branch named “feature”, use: git branch feature Here’s the basic git branch usage to list all existing branches: git branch Use this command to manage branches in your Git repository. For example, enter this command to set your email address for commits: git config -global user.email –global flag applies the configurations universally, impacting your local repository. This command configures various aspects of Git, including user information and preferences. To move a file to a different directory, enter: git mv file1.txt new_directory/ Here’s the Git command to rename a file: git mv file1.txt file2.txt Use this command to rename and move files within your working directory. This command removes files from your working directory and stages the removal for the next commit. To compare changes between two commits, use the following: git diff commit1 commit2 For example, this git diff usage identifies the differences in a specific file: git diff file1.txt This command lets you compare changes between your working directory and the most recent commit. The basic git log usage lets you view a chronological list of commit history: git log This command displays valuable insights into your files’ modifications and staging status. Use this command to create a commit message for the changes, making them part of your project’s history: git commit -m "Add new feature" This command is used to stage file changes, preparing them for the next commit: git add file1.txt To create a new repository while specifying the project’s name, use the following command: git init Here’s the basic git init usage: git init This command initiates a new Git repository within a directory. Let’s explore some essential Git commands and their functionalities. If you prefer a graphical user interface (GUI) for writing Git commands, consider using one of the best Git GUI clients. Fortunately, this section will guide you through the most frequently used Git commands in the command line interface (CLI) tool. Or sudo dnf install git Most Commonly Used Git Commandsįor some users, Git may have a steep learning curve. If you’re using a Hostinger VPS hosting plan, you can install Git directly to your server by typing one of the commands below depending on your installed OS:įor Debian-based distributions, including Ubuntu: sudo apt install gitįor Fedora-based distributions, such as CentOS: sudo yum install git It is available for Linux or Unix, Windows, and macOS. Git can be downloaded from its official site. After you commit your modifications, a snapshot of the changes will be saved in the directory. Then, the changes are indexed in the staging area. The working directory is where you add, delete, and edit files. A2.A Git project consists of three major sections: the working directory, the staging area, and the git directory.Git in IntelliJ / P圜harm / WebStorm / PhpStorm / RubyMine If you see an error or have a suggestion, patches and issues are welcome in its GitHub repository. The version found here has been updated with corrections and additions from hundreds of contributors. Print versions of the book are available on. All content is licensed under the Creative Commons Attribution Non Commercial Share Alike 3.0 license. The entire Pro Git book, written by Scott Chacon and Ben Straub and published by Apress, is available here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |