Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

top git commands

git code .                                //Open vs code
git status                                //Show file status
git status -s                             //show short file status
git add <filename>                        //Add the particular file to staging area
git add .                                  //Add all the file to the staging area
git commit --amend                        //Add these changes to the last commit (will have to use vim editor)
git commit -m "message"                   //Commit the files in the staging area    
git commit -am "message"                  //Will commit without adding the file to the staging area
git checkout --<filename>                 //will restore the file from the last commit
git checkout -f                           //All the files will be replaced with last commit
git checkout -b <branch name> 		   	  //Create a branch
git branch 								//To see the branches
git branch -d <branch name>				//To delete a branch
git branch -v 							//will show the branch and its last commit
git branch --merged 					//will show the branches that are merged
git branch --no-merged 					//will show the branches that are not merged
git merge <branch name>					//while in a branch you can merge another branch
git log                                   //Show all the commits
git log -n                                //n can be replaced by any number "will show last n commits"
git log -p                                //Will show detailed discription of the commits  
git log -p -n                             //use of n is similar as described above  
git log --stat                            //will show short detailing of the commits  
git log --stat -n                         //use of n is similar as described above    
git log --since=n.days                    //commit of last n days/weeks/months "days can be replaced by weeks,months"
git rm --cached <filename>                //will remove to file from the tracking area 
git rm -rf                                //will uninitialized the current repository              
git rm <filename>                         //will delete the file  
git mv <Present filename> <The filename after the change>  //to Rename the file
git clone <URL>                           //Cloning a repository in the current folder
git clone <URL> foldername                //Cloning the repository in the given folder name (Folder will be created by itself) 
git config --global alias. <new name> 'old command'  //while create an alias command for the given command
git remote 						//Show all the name of remote repository
git remote -v 					//Show all the path (fetch/push) of the remote repository
git remote add <name> url			//Add a remote repository
git remote rm <name>				//To remove a remote
git push <remote name> <branch name>	//To push a branch to remote repository
git push <remote name> <branch name>:<branch name you want to have in the remote repository>
git reset HEAD						//To move to a previous commit



More commands can be found on this website
//website https://git-scm.com/docs/git-log
Comment

basic 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

basic git commands

Basic Git commands



https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html
Comment

popular git command

git fetch --all

# create new branch from origin `main` branch.
git checkout -b prefix/new_branch_name origin/staging

# commit and push your work to your own branch.
git commit -m "<type>(scope?): <message>"
git push

# update new codes from origin `staging` branch.
git pull --rebase origin staging
git push --force
Comment

PREVIOUS NEXT
Code Example
Shell :: codeception environnement variable not found 
Shell :: putting remote access to rpi zero 
Shell :: gunicorn gevent websocket 
Shell :: sed wrap each line in quotes 
Shell :: mac workbench error loading schema content 1558 
Shell :: windows powershell ise 
Shell :: git commit -am "make it better" error 
Shell :: linux traverse all subdirectories and do action 
Shell :: Install Chef Habitat from the Command Line 
Shell :: @ module not install webstorm vue 
Shell :: minecraft launcher installations gone 
Shell :: agregar sudoers a user centos 7 
Shell :: fast rename fasta header 
Shell :: generalized curl 
Shell :: Show CSF version 
Shell :: registry key programfilesdir 
Shell :: dockerd failed to start daemon: failed to get temp dir to generate runtime scripts 
Shell :: ubuntu 18.04 create folders in dock 
Shell :: get to directory downloads in ubuntu 20.04 using terminal 
Shell :: debian buster add ip alias cli 
Shell :: how to open pg_hba.conf file in ubuntu using visual studio 
Shell :: the folder cannot be copied because you do not have permissions to create it in the destination 
Shell :: how to install bully on ubuntu 20.04 
Shell :: Wrong number of arguments for specified --cluster sub command 
Shell :: git bash authentication failed not asking for password 
Shell :: ubuntu vmware mouse buttons 
Shell :: step2 pgadmin ubuntu 20.04 
Shell :: remove pob kubernetes 
Shell :: git commands cheat sheet pdf 
Shell :: ssh key location windows 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =