What is Git?
Git is a free, open source distributed version control system tool designed to handle everything from small to very large projects with speed and efficiency. Git has the functionality, performance, security and flexibility that most teams, individual developers and researchers need. It was created by Linus Torvalds in 2005 to develop Linux Kernel.
What is the purpose of Git?
Git is primarily used to manage your project, comprising a set of code or text files that may change that may change over time.
Git is also used to save your remotely and allow access to multiple individuals for updates.
Here are 15 git commands to master for a start
This command is used to initialize or start a new git repo
see sample below. Navigate into the folder you're initializing if it already exist, or simply create a new one.
git config command sets the author name and email address respectively to be used with your commits.
This command is used to obtain or download a repository
from an existing source.
This command is used to add a single file or multiple files to a staging area. Note that, the added file(s) won't be on your remote environment until they're pushed.
Here are some
git add commands
git add filenameadds a file called "filename" to the staging area
git add .stages new files and modifications, without deletions
git add -Astages all changes
git add -ustages modifications and deletions, without new files
This command records or snapshots the file permanently in the version history.
Here are some
git commit commands
git commit -m "My First Commit"gives you the opportunity to add a commit message.
git commit -acommits any files you’ve added with the git add command and also commits any files you’ve changed since then.
This command is used to connect your local repository to the remote server.
This command lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.
The command is a primary command used to download contents from a remote repository. This content includes branches and tags.
This command is used to switch from one branch to another.
This command can be used to create a new branch. To create a new
git checkout -b my-new-branch where "my-new-branch" is the name of the new branch.
This command sends information committed to your remote repository. when using
git push you can there are multiple way commits can be pushed to the remote.
git push [remote-variable-name] [branch-name]this command pushes commits staged on a particular branch to a remote origin, example
git push origin masterwe can also have
git push heroku my-new-branch.
git push allthis command pushes all branches to your remote repository.
git push -forceor
git push -fthis command forcefully send the current staged commit to the remote repository.
git push -u origin masteris used for pushing staged content to GitHub. In the code, the origin is your default remote repository name and
-uflag is upstream, which is equivalent to
-set-upstreamand the master is the branch name.
This command fetches and merges changes on the remote server to your working directory.
This command temporarily stores all the modified tracked files. this command can also be used to check all new modifications and move them to a new branch.
git stash popthis command restores the most recently stashed files on the current branch.
git stash listthis command lists all stashed changes.
git stash dropthis command discards the most recently stashed changes.
This command merges the specified branch’s history into the current branch.
This command lists all the local branches in the current repository. This command can also be used to create a new branch or delete an existing branch.
git branch new-branch-namethis command creates a new branch called "new-branch-name".
git branch -d [branch-name]this command deletes the feature branch.
This command is used to list the version history for the current branch.
You can start by practicing these few git commands, using them constantly also helps to learn them faster. I hope you have a great learning experience.
To get a more in-depth knowledge of git please click here learn git