Giter Club home page Giter Club logo

ds_gitcommands's Introduction

gitCommands

In order to explore different commands in Git, you need to have a github account.

Follow the below link to create a new account in github.

https://help.github.com/articles/signing-up-for-a-new-github-account/

How to create and start using the new Repo?

How to create a Repository in GIT ?

  • Click on the new repository link and create a repo in Git.

  • Click the Create Repository button.

  • Once the repository is successfully created then the below page will be displayed.

How to start using a Repository in GIT ?

  • Create a folder in your machine where you want to start using the new repository.

  • Follow the commands given below.

echo "# abc" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/dilipSundar/abc.git
git push -u origin master
  • Congratulations , by completing the above steps you have successfully completed the pushing the code from your local to remote.

How to start using the existing Repo?

  • Clone the repository
  • Click on the clone or download button.
  • Copy the link

git clone <copied-link>

  • You have successfully cloned the repo. You can start working on that code.

How to create a branch in git?

git checkout -b <branch-Name>

How to push the changes to git ?

  • Modify the code/file.

  • Run the below command to check the changed file.

git status
  • There are three steps to push the code to github.

    • add
    • commit
    • push
  • Follow the below commands.

git add .

git commit -m '<change comments> '

git push origin <branch-name>

How to pull the changes from git ?

git pull origin <branch-name>

How to merge changes from one branch to another branch?

  • Merging someother branch changes in to your branch.
git merge <branch-name>

FORK:

Steps to Fork and keep the forked repo in sync:

Follow this link for the steps that need to be followed.

https://help.github.com/articles/fork-a-repo/

How to stop git tracking files/folder?

For Example:

If we want to stop ignoring the .idea folder then add the below line in the .gitignore file .

.gitignore file:

.idea/

Folder :

If the folder is already a part of the git repo then run the below command to remove it from the git repo.

The below command will remove the folder from the git repo.

git rm -r --cached <folder>

For Example : To remove the .idea folder run the below command.

git rm -r --cached .idea/

File :

If the file is already a part of the git repo then run the below command to remove it from the git repo.

git rm --cached <file>

How to remove untracked files ?

Folder:
This will delete the untracked folder.

git clean -fd

How to Unstage the staged files ?

The below command will unstage the staged files.

git reset HEAD

How to merge unrelated histories ?

fatal: refusing to merge unrelated histories
  • To solve the above issue we need to run the below command

git pull origin <branchname> --allow-unrelated-histories

ds_gitcommands's People

Contributors

dilipthelip avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.