Code Monkey home page Code Monkey logo

git-helper-cmd's Introduction

Git-helper-cmd

Git Config

git config --global user.name "John Doe" Git user Config

git config --global user.email [email protected] Git user Config

git config --list

git config --list --show-origin to see where that setting is defined (global, user, repo, etc...)

Git initiation & basics

git init Initialize Git

git add file-name.txt Staged all files (i.e. staged new files in git & to make ready to push in git repository)

git status View file status (View current status of files)

pwd Present Work Directory

ls Show all files in the directory

ls -a Show all files in the directory

clear Clear Terminal

rm dir name Remove directory

rm -r dir name Remove recursively directory

cd .. Back 1 upper

git add --all Added all files to stage

git commit -m "msg" Commit message to changed files

git commit -am "msg" file1 name file2 name Commit message to all file

git commit -am "all 2 Commit" Example

git switch command to do the same since git checkout

git push (-u or --set-upstream) origin Allows you to specify the upstream (remote) repository for the branch you're on, so that next time you run git push, you don't even have to specify the remote repository.

Next time you push, you don't have to specify the remote repository

git push

Copy changes from one branch to another I have a branch named BranchA from master. I have some changes in BranchA (I am not going to merge changes from BranchA to master). Now I have created another branch from master named BranchB. How can I copy the changes from BranchA to BranchB?

git checkout BranchB
git merge BranchA

Instead of merge, as others suggested, you can rebase one branch onto another:

git checkout BranchB
git rebase BranchA

This takes BranchB and rebases it onto BranchA, which effectively looks like BranchB was branched from BranchA, not master.

Git pull origin branchName Bring remote changes to local repo

Ignore files and folder git

stackoverflow

Some files are libraries/documentation you don't want to delete but also don't want to push to github. Let say you have your project in folder your_project and a doc directory: your_project/doc

Create git ignore file first-- touch .gitignore

this command to add lines in your gitignore file-- echo 'application/cache' >> .gitignore

And you can exclude a folder by entering the below command in the .gitignore file /folderName

  • Remove it from the project directory (without actually deleting it): git rm --cached doc/*
  • If you don't already have a .gitignore , you can make one right inside of your project folder: project/.gitignore .
  • Put doc/* in the .gitignore
  • Stage the file to commit: git add project/.gitignore
  • Commit: git commit -m "message".
  • Push your change to github.

We can unignore certain files in a deeper structure or a specific subset (ie, you ignore *.log but want to still track important.log) by specifying patterns beginning with !. eg: *.log !important.log

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.