I Want to Use Command Line to Upload Files to Git

Bones GIT Commands

Basic GIT Commands

Download Complete Git Cheat Sheet

Demand to learn some basic GIT commands? You lot've come to the right place. Read on to discover our handy cheat sheet that you can apply for daily reference.

Let's get started!

Agreement the GIT Workflow

GIT is the most widely used open-source VCS (version control system) that allows y'all to track changes made to files. Companies and programmers usually use GIT to collaborate on developing software and applications.

A GIT projection consists of 3 major sections: the working directory, the staging surface area, and the git directory.

The working directory is where yous add, delete, and edit the files. Then, the changes are staged (indexed) in the staging area. After you lot commit your changes, the snapshot of the changes will be saved into the git directory.

Everyone can use GIT as it is available for Linux, Windows, Mac, and Solaris. The software may have a steep learning curve, but at that place are lots of GIT tutorials ready to help you lot.

Bones GIT Commands

Hither are some basic GIT commands you need to know:

  • git init volition create a new local GIT repository. The following Git control will create a repository in the current directory:
git init
  • Alternatively, you can create a repository within a new directory by specifying the project proper noun:
git init [projection name]
  • git clone is used to re-create a repository. If the repository lies on a remote server, use:
git clone username@host:/path/to/repository
  • Conversely, run the following basic command to copy a local repository:
git clone /path/to/repository
  • git add is used to add files to the staging area. For example, the bones Git following command volition index the temp.txt file:
git add together <temp.txt>
  • git commit will create a snapshot of the changes and salve it to the git directory.
git commit –chiliad "Bulletin to go with the commit here"
  • Note that any committed changes won't make their way to the remote repository.

  • git config tin be used to set user-specific configuration values similar email, username, file format, and so on. To illustrate, the control for setting up an e-mail will await like this:
git config --global user.electronic mail youremail@example.com
  • The –global flag tells GIT that you lot're going to use that email for all local repositories. If you want to use different emails for different repositories, utilize the command below:
git config --local user.email youremail@example.com
  • git status displays the list of inverse files together with the files that are yet to exist staged or committed.
git condition
  • git push is used to send local commits to the master branch of the remote repository. Hither's the basic code structure:
git push origin <master>
  • Supervene upon <chief> with the co-operative where you want to push button your changes when you're not intending to push button to the master branch.

  • git checkout creates branches and helps you to navigate between them. For example, the following basic command creates a new branch and automatically switches you to information technology:
command git checkout -b <branch-name>
  • To switch from ane branch to some other, simply use:
git checkout <branch-name>
  • git remote lets you view all remote repositories. The following command volition list all connections along with their URLs:
git remote –5
  • To connect the local repository to a remote server, use the command below:
git remote add origin <host-or-remoteURL>
  • Meanwhile, the following control will delete a connection to a specified remote repository:
git remote rm <proper noun-of-the-repository>
  • git branch will list, create, or delete branches. For instance, if y'all want to list all the branches nowadays in the repository, the command should expect like this:
git branch
  • If yous want to delete a co-operative, use:
git branch –d <co-operative-name>
  • git pull merges all the changes present in the remote repository to the local working directory.
git pull
  • git merge is used to merge a branch into the active ane.
git merge <branch-name>
  • git diff lists down conflicts. In order to view conflicts confronting the base file, use
git diff --base <file-name>
  • The post-obit bones control is used to view the conflicts between branches before merging them:
git unequal <source-branch> <target-branch>
  • To list downward all the present conflicts, utilise:
git diff
  • git tag marks specific commits.  Developers usually use it to mark release points like v1.0 and v2.0.
git tag <insert-commitID-hither>
  • git log is used to encounter the repository's history past listing certain commit's details. Running the command will get y'all an output that looks like this:
commit 15f4b6c44b3c8344caasdac9e4be13246e21sadw Writer: Alex Hunter <alexh@gmail.com> Date:   Mon Oct 1 12:56:29 2016 -0600
  • git reset command volition reset the index and the working directory to the last git commit's state.
git reset --difficult Caput
  • git rm can exist used to remove files from the index and the working directory.
git rm filename.txt
  • git stash command will temporarily save the changes that are not prepare to be committed. That style, you can become back to that projection after.
git stash
  • git show is a command  used to view information nearly whatever git object.
git show
  • git fetch allows users to fetch all objects from the remote repository that don't currently reside in the local working directory.
git fetch origin
  • git ls-tree allows you to view a tree object along with the name, the mode of each particular, and the blob'south SHA-1 value. Let'due south say you want to meet the Head, use:
git ls-tree HEAD
  • git cat-file is used to view the type and the size information of a repository object. Employ the -p option forth with the object's SHA-one value to view the data of a specific object, for example:
git cat-file –p d670460b4b4aece5915caf5c68d12f560a9fe3e4
  • git grep lets users search through committed copse, working directory, and staging expanse for specific phrases and words. To search for world wide web.hostinger.com in all files, use:
git grep "world wide web.hostinger.com"
  • gitk shows the graphical interface for a local repository. Simply run:
gitk
  • git instaweb allows you to scan your local repository in the git-web interface. For example:
git instaweb –httpd=webrick
  • git gc will clean unnecessary files and optimize the local repository.
git gc
  • git archive lets users create a zip or a tar file containing the constituents of a single repository tree. For instance:
git archive --format=tar master
  • git clip deletes objects that don't accept any incoming pointers.
git clip
  • git fsck performs an integrity check of the git file organisation and identifies any corrupted objects.
git fsck
  • git rebase is used to apply certain changes from one branch to another. For instance:
git rebase master

Basic GIT Commands Cheat Canvas in .pdf

If y'all are just starting out with GIT, it can exist hard to retrieve even the basic commands. For that reason, we've put together a GIT crook sheet to assistance y'all principal the software. Salve the file to your devices or print it out then you'll e'er accept information technology ready when y'all're stuck remembering GIT commands.

Download (size:1.2MB)

Decision

Learning basic GIT commands will go a long way for developers every bit they can easily control the projects' source code. Information technology might accept some time to commit to remembering all of them, simply hopefully, our GIT crook sail will exist helpful for you.

Practice those commands and make the most of your developing skills! Proficient luck!

Author

Domantas leads the content and SEO teams frontwards with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing noesis, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to strop his spider web evolution skills and travel to exotic places.

grahamancomettiody.blogspot.com

Source: https://www.hostinger.com/tutorials/basic-git-commands

0 Response to "I Want to Use Command Line to Upload Files to Git"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel