GithubHelp home page GithubHelp logo

git-commands's Introduction

How to Write a Git Commit Message

https://chris.beams.io/posts/git-commit/

Git commands for merging your local directory with a remote repository

Create new repo

  1. Create new repository on github
  2. copy https code downlod url
  3. In Git bash do:

git clone https://restoftheurl.com/repositorymadejjustnow.git

# make sure to not use ctrl+v to paste in git bash, it will add hidden ^? or something.

git init

git add . git commit -m "first commit"

First create a local repository

git remote add origin

add remote repository origin to local repository

git pull origin master

merge the two repsitories

Git-commands

Basic Git commands for future reference

to add ssh key to Github

Open ~/.ssh/id_rsa.pub and then copy the key from the file. At last add the key in the github ssh keys in settings.

git config

git config --global user.name "name"

git config --global user.email "email"

git clone (When staring a new remote repository, it's better to use git clone)

git clone url-of-repository

git init

create a git repository

git diff

show all the changes made

git add file-name

add to the changes you want to track

git commit -m "message"

save a version of this repository

git commit -am "message"

add + commit

git status

shows currentstatus of repository

git push / git push origin master

send commited changes to remote repository

git pull

pull the changes made in the remote repository

git log

shows history of commits and messages

git reset --hard #commit

reset to a previous commit

git reset --hard origin/master, back to remote repository version


Merge conflicts

int a = 1;
<<<<<<<<<<<< HEAD
int b = 2;
============
int b = 0;
>>>>>>>>>>>> 5428973695827389457345e
int c = 3;
int d = 4;

Keep the line you want to keep and delete everything else in the conflict


Branching

git branch

shows all branches

git branch branch-name

new branch

git checkout branch-name

switch to a branch

git checkout -b branch-name

new branch and switch to it

git merge branch-name

merges with current branch

git branch -D branch-name

delete branch (-d gives a soft delete)

Merging two separately origined repositories

git pull origin branchname --allow-unrelated-histories

git-commands's People

Contributors

vipinindkumar avatar

Watchers

 avatar  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.