Git Intro for Beginners

Git Intro for Beginners:

 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

git init
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
The git config command sets the author name and email address respectively to be used with your commits.

git clone
This command is used to obtain or download a repository 
from an existing source.

git add
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 filename adds a file called “filename” to the staging area
  • git add . stages new files and modifications, without deletions
  • git add -A stages all changes
  • git add -u stages modifications and deletions, without new files

git commit
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 -a commits any files you’ve added with the git add command and also commits any files you’ve changed since then.

git remote
This command is used to connect your local repository to the remote server.

git status
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.

git fetch
The command is a primary command used to download contents from a remote repository. This content includes branches and tags.

git checkout
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.

git push
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 master we can also have git push heroku my-new-branch.
  • git push all this command pushes all branches to your remote repository.
  • git push -force or git push -f this command forcefully send the current staged commit to the remote repository.
  • git push -u origin master is used for pushing staged content to GitHub. In the code, the origin is your default remote repository name and -u flag is upstream, which is equivalent to -set-upstream and the master is the branch name.

git pull
This command fetches and merges changes on the remote server to your working directory.

git stash
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 pop this command restores the most recently stashed files on the current branch.
  • git stash list this command lists all stashed changes.
  • git stash drop this command discards the most recently stashed changes.

git merge
This command merges the specified branch’s history into the current branch.

git 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-name this command creates a new branch called “new-branch-name”.
  • git branch -d [branch-name] this command deletes the feature branch.

git log
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.

from Tumblr https://generouspiratequeen.tumblr.com/post/635143628038275072

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s