Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

primary git commands

# Main git commands

# Configurations

git config --global user.name "Sam Smith"
git config --global user.email sam@example.com

# New Repository

git init

# Copy local repository

git clone /path/to/repository 

# Copy local repository for remote servers

git clone username@host:/path/to/repository

# Add files

git add <filename>

git add *

# Git Commits

git commit -m "Commit message"

# Commit any files added with git add command

git commit -a

# Push changes to master branch

git push origin master

# Check the status of files

git status

# Connect to remote repository

git remote add origin <server>

# Provide a list of recently configured remote repositories

git remote -v

# Create new branch then switch to it

git checkout -b <branchname>

# Switch branches

git checkout <branchname>

#List all branches in repository

git branch

# Delete the feature branch 

git branch -d <branchname>

# Push selected branch to your remote repository

git push origin <branchname>

# Push all branches to remote repository

git push --all origin

# Delete a branch on the remote repository

git push origin :<branchname>

# Fetch and merge changes on remote server to certain directory

git pull

# Merge a different branch into active branch

git merge <branchname>

# View merge conflicts

git diff

git diff --base <filename>

git diff <sourcebranch> <targetbranch>

# Mark changed file

git add <filename>

# Utilise tagging to mark a certain changeset

git tag 1.0.0 <commitID>

# Get changeset ID

git log

# Push all tags to remote repository

git push --tags origin

# Undo local changes, replace changes

git checkout -- <filename>

# Drop all changes and commits

git fetch origin

git reset --hard origin/master

# Search the working directory for foo(); (example)

git grep "foo()"
Comment

PREVIOUS NEXT
Code Example
Shell :: github command 
Shell :: sail add php mongodb extension 
Shell :: pwd linux 
Shell :: git discard all unpushed commits 
Shell :: create flutter project command line 
Shell :: How install packages from package.tar.gz on rstudio 
Shell :: npm version 
Shell :: how to read from keyboard in bash and store in a variable 
Shell :: uniq bash sort 
Shell :: pip install requireents 
Shell :: check laptop battery health using upower 
Shell :: how to add key pair to ec2 instance terraform 
Shell :: install django debian 
Shell :: how to run shell script 
Shell :: Simulate keys with powershell 
Shell :: debian without gui 
Shell :: npm not found in zsh 
Shell :: github add image to readme 
Shell :: user current process in linux 
Shell :: git pull from commit 
Shell :: docker remove image 
Shell :: bash random int 
Shell :: create patch in git 
Shell :: windows change hostname 
Shell :: chmod 400 in powershell 
Shell :: git bash posh git 
Shell :: -bash: docker: command not found mac 
Shell :: bash script command not found 
Shell :: how to upgrade to wsl 2 
Shell :: ubuntu copy 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =