Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git commands

 …or create a new repository on the command line
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/metinkaya1511/FinraDeck.git 
(GitHub’daki adres)
git push -u origin master
…push an existing repository from the command line
git remote add origin https://github.com/metinkaya1511/FinraDeck.git  
(github adresi)
git push -u origin master 
CREATE BRANCH
-   git branch develop ==> it creates new branch named 'develop' but still 
keep being on master branch
-   git checkout develop ==> it will change your branch to the develop branch
git checkout -b develop ==> it creates also a branch named develop and 
switches to it automatically
DELETE
git branch -d <branch_name> deletes the branch. If we have unmerged changes, 
this command gives a warning and does not delete.  
git branch -D <branch_name> deletes the branch even if it has unmerged changes.
Gives no warning.
SWITCH to Branch
git checkout develop checks out the branch, switches to the branch.
git checkout -b <branch_name> creates a new branch and switches to it.  
git merge <branch_name>  this command takes changes from the given branch, 
and merges with the current branches we are on. 
Comment

git commands

> git add
Moves changes from the working directory to the staging area. 
This gives you the opportunity to prepare a snapshot before committing it to the official history.

> git branch
This command is your general-purpose branch administration tool. 
It lets you create isolated development environments within a single repository.

> git checkout
In addition to checking out old commits and old file revisions, git checkout is also the means to navigate existing branches. 
Combined with the basic Git commands, it’s a way to work on a particular line of development.

> git clean
Removes untracked files from the working directory. 
This is the logical counterpart to git reset, which (typically) only operates on tracked files.

> git clone
Creates a copy of an existing Git repository. 
Cloning is the most common way for developers to obtain a working copy of a central repository.

> git commit
Takes the staged snapshot and commits it to the project history. 
Combined with git add, this defines the basic workflow for all Git users.

> git commit --amend
Passing the --amend flag to git commit lets you amend the most recent commit. 
This is very useful when you forget to stage a file or omit important information from the commit message.

> git config
A convenient way to set configuration options for your Git installation. 
You’ll typically only need to use this immediately after installing Git on a new development machine.

> git fetch
Fetching downloads a branch from another repository, along with all of its associated commits and files. 
But, it does not try to integrate anything into your local repository. 
This gives you a chance to inspect changes before merging them with your project.

> git init
Initializes a new Git repository. 
If you want to place a project under revision control, this is the first command you need to learn.

> git log
Lets you explore the previous revisions of a project. 
It provides several formatting options for displaying committed snapshots.

> git merge
A powerful way to integrate changes from divergent branches. 
After forking the project history with git branch, git merge lets you put it back together again.

> git pull
Pulling is the automated version of git fetch. 
It downloads a branch from a remote repository, then immediately merges it into the current branch. 
This is the Git equivalent of svn update.

> git push
Pushing is the opposite of fetching (with a few caveats). 
It lets you move a local branch to another repository, which serves as a convenient way to publish contributions. 
This is like svn commit, but it sends a series of commits instead of a single changeset.

> git rebase
Rebasing lets you move branches around, which helps you avoid unnecessary merge commits. 
The resulting linear history is often much easier to understand and explore.

> git rebase -i
The -i flag is used to begin an interactive rebasing session. 
This provides all the benefits of a normal rebase, but gives you the opportunity to add, edit, or delete commits along the way.

> git reflog
Git keeps track of updates to the tip of branches using a mechanism called reflog. 
This allows you to go back to changesets even though they are not referenced by any branch or tag.

> git remote
A convenient tool for administering remote connections. 
Instead of passing the full URL to the fetch, pull, and push commands, it lets you use a more meaningful shortcut.

> git reset
Undoes changes to files in the working directory. 
Resetting lets you clean up or completely remove changes that have not been pushed to a public repository.

> git revert
Undoes a committed snapshot. 
When you discover a faulty commit, reverting is a safe and easy way to completely remove it from the code base.
Comment

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

git basic commands

git clone
git fetch
git pull
git commit
git push
Comment

git commands

git init
git add *Enter File Name Here*
git commit -m "first commit"
git remote add origin *Enter URL Here*
git push -u origin master
Comment

git commands

echo "# New-Projects" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/hussainbabar/New-Projects.git
git push -u origin main
Comment

all 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

git basic commands

git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:xyz/reponame.git
git push -u origin main
Comment

Git Basic commands

// Git Basic commands
git init
  - Initializes the current folder as a git repository 

git status
  - Current status of the folder 

git add path/to/file
 - To add a particular file

git add .
  - add all files staging area -
 
git commit -m "First commit"
  - commit the changes to the git repository

git log --oneline
 - see a brief log of commits in line by line

git log
 - see a brief log of commits with author and date

git checkout <commit> <file>
  - checkout the file from an older commit

git checkout -- <file> 
 - to discard changes in working directory

git reset <file>
  - unstage a staged file, but leave working directory unchanged

git reset
  - reset the staging area to the last commit without disturbing the working directory
Comment

git commands

git config -l
Comment

Git Commands List

//To add file in commit
git add filePath

//To Commit with message
git commit -m 'Commit message'

//To revert file changes to its head. Replace with head
git checkout -- libs/logs/advertiserApi/advertiserApi.log

//To skip ng lint and commit the code
git commit -m 'ng lint error reverted back' --no-verify

//To reset commit below command
// Below HEAD~1 means it will reset to last 1 commit, HEAD~2 means it will reset to last 2 commits.
git reset HEAD~1
git reset HEAD~2
git reset HEAD~3

git reset --soft HEAD^
git reset --hard HEAD^

//To merge and resolve conflict by using Ours changes or Theirs changes.
git checkout --Xours --Xtheirs

git merge --abort

//To create new branch
git branch branchName

//Display all branches
//For local branches
git branch 
//For remote branches
git branch -r

// delete branch locally
git branch -d localBranchName

// delete branch remotely
git push origin --delete remoteBranchName

//Git stash changes temporary
git stash save "Saving data of story"

//View stashes
git stash list

//Bring stash back and remove from stash
git stash pop

//Bring stash back and keep in stash
git stash apply

//Remove from stash
git stash drop

Comment

git commands

git push -u origin branch_name
Comment

git command

echo "# Cryptocurrency" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/pkbhavsar1/Cryptocurrency.git
git push -u origin main
Comment

git basic commands

git commit -m "Commit message"
Comment

git basic commands

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

git command

git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
Comment

git basic commands

git clone /path/to/repository
Comment

git commands

git commit -a -m"your commit message here"
Comment

basic git commands

Basic Git commands



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

Git command

> git pull 
> git add . 
> git commit -m "added new cool feature! Spinning asteroids!!!" 
> git push
Comment

git command

git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
Comment

Git Commands

Some basic Git commands are:
```
git status
git add
git commit
```
Comment

git commands

git rebase -i master
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
Comment

git commands

git commit
Comment

git commands

git commit -m "your commit message here"
Comment

git commands

git branch -d branch_name
Comment

git basic commands

git push origin <branchname>
Comment

git commands

git config --global user.email "signups@fabiopacifici.com"
Comment

git commands

git log --graph --oneline --all
Comment

git basic commands

git checkout -b <branchname>
Comment

git basic commands

git push --all origin
Comment

git commands

git log origin/main
Comment

git commands

git branch branch_name
Comment

git commands

git checkout branch_name
Comment

git commands

git checkout -b branch_name
Comment

git commands

git merge branch_name
Comment

git commands

git log --graph --oneline
Comment

git commands

git add remote https://repo_here
Comment

git commands

git rebase branch_name_here
Comment

git commands

git merge origin/main
Comment

git commands

git remote update
Comment

git commands

git push --delete origin branch_name_here
Comment

git command

echo "# alx-zero_day" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Aylinkup/alx-zero_day.git
git push -u origin main
Comment

git command

git remote add origin https://github.com/Aylinkup/alx-zero_day.git
git branch -M main
git push -u origin main
Comment

git commands

git reset HEAD filename
git reset HEAD -p
Comment

git command

git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
Comment

git commands

git revert comit_id_here
Comment

git basic commands

git branch -d <branchname>
Comment

git commands

git mv oldfile newfile
Comment

git basic commands

git push --tags origin
Comment

git basic commands

git add <filename>

git add *
Comment

git basic commands

git push origin :<branchname>
Comment

git basic commands

git merge <branchname>
Comment

git basic commands

git diff <sourcebranch> <targetbranch>
Comment

git basic commands

git add <filename>
Comment

git basic commands

git tag 1.0.0 <commitID>
Comment

git basic commands

git fetch origin

git reset --hard origin/master
Comment

git commands

git rm filename
Comment

git commands

git config --global user.name "Fabio"
Comment

git commands

git add filename_here
Comment

git commands

git add fil*
Comment

git commands

git show commit-id
Comment

git commands

git diff
git diff all_checks.py
git diff --staged
Comment

git commands

git add -p
Comment

git command

git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
Comment

PREVIOUS NEXT
Code Example
Shell :: how to install xdm ubuntu 20.04 
Shell :: install ruby on rails ubuntu 
Shell :: remove git remote 
Shell :: Go install /linux 
Shell :: .desktop file ubuntu 
Shell :: kubernetes auto complete 
Shell :: rhythmbox 
Shell :: initialize github repository 
Shell :: uploading a folder to github 
Shell :: bash see size of directory 
Shell :: command not found: yarn 
Shell :: wsl install 
Shell :: how to add the permission in the lampp in ubuntu 
Shell :: brew portkill 
Shell :: Unable to install APK to device. Please make sure the Android SDK is installed and is properly configured in the Editor. 
Shell :: git create new repo 
Shell :: echo to file 
Shell :: sudo npm cache clean -f 
Shell :: git change local branch name 
Shell :: stop port 
Shell :: git clone command 
Shell :: bin/sh sam: not found 
Shell :: multiple kubeconfig in one file 
Shell :: docker compose install ubuntu 
Shell :: debian backports 
Shell :: npm install bootstrap 3 
Shell :: where to find zshrc mac 
Shell :: run pm2 in cluster mode 
Shell :: bash ls show link 
Shell :: ubuntu move all files in directory 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =