git commands

160

 …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. 
> 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.
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
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
# Main git commands

# Configurations

git config --global user.name "Sam Smith"
git config --global user.email [email protected]

# 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()"
git config -l
git push -u origin branch_name
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
git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
git commit -a -m"your commit message here"
git log --graph --oneline --all
> git pull 
> git add . 
> git commit -m "added new cool feature! Spinning asteroids!!!" 
> git push
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
git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main
Some basic Git commands are:
```
git status
git add
git commit
```
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
git commit
git commit -m "your commit message here"
git show commit-id
git branch -d branch_name
git add -p
git config --global user.email "[email protected]"
git config --global user.name "Fabio"
git add filename_here
git add fil*
git diff
git diff all_checks.py
git diff --staged
git rm filename
git mv oldfile newfile
git reset HEAD filename
git reset HEAD -p
git revert comit_id_here
git branch branch_name
git checkout branch_name
git checkout -b branch_name
git log --graph --oneline
git add remote https://repo_here
git log origin/main
git merge origin/main
git remote update
git push --delete origin branch_name_here
git rebase branch_name_here
git remote add origin https://github.com/Aylinkup/alx-zero_day.git
git branch -M main
git push -u origin main


git commit --amend --no-edit // ammends previous commit with same commit message
git checkout HEAD filename // Discards changes in the working directory
git reset HEAD filename // Unstages file changes in the staging area
git reset commit_SHA // Resets to a previous commit in your commit history
***************************************************************************
vi commands
i // enter edit mode
esc // enter command mode
command
:wq	      Save and quit
:w	      Save
:q	      Quit
:w fname  Save as fname
ZZ	      Save and quit
:q!	      Quit discarding changes made
:w!	      Save (and write to non-writable file)

***************************************************************************
Edit a specific commit
Use git rebase. For example, to modify commit bbc643cd, run:

$ git rebase --interactive 'bbc643cd^'
Please note the caret ^ at the end of the command, because you need actually to rebase back to the commit before the one you wish to modify.

In the default editor, modify pick to edit in the line mentioning bbc643cd.

Save the file and exit. git will interpret and automatically execute the commands in the file. You will find yourself in the previous situation in which you just had created commit bbc643cd.

At this point, bbc643cd is your last commit and you can easily amend it. Make your changes and then commit them with the command:

$ git commit --all --amend --no-edit
After that, return back to the previous HEAD commit using:

$ git rebase --continue
WARNING: Note that this will change the SHA-1 of that commit as well as all children -- in other words, this rewrites the history
 from that point forward. You can break repos doing this if you push using the command git push --force.

It's worth noting that you may need to run git stash before git rebase and git stash pop afterwards, if you have pending changes.
***************************************************************************
echo "# cs50" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/clickdemy/cs50.git
git push -u origin main
git remote add origin https://github.com/clickdemy/cs50.git
git branch -M main
git push -u origin main
git merge branch_name
git remote add origin https://github.com/sathish2519/dice-js.git
git branch -M main
git push -u origin main

Comments

Submit
0 Comments

More Questions

cmd cant change directoryhow to open d drive using conda prompt how to add basic authentication on haproxy backend server
cmd cd not workingvideo player html express hello world
form submit with file upload in phpcreate latex document button avalonia
simple deployment diagram for basic crud operationsc# sockets guzzlehttp authorization basic
using axios get with authorizationpehkui mod forge c# restclient get basic authentication
curl authJASON WEB TOKENS EM VBNET COM WINDOWS FORMS git commands
c64 basic define variableauthentication in fetch post how to create authentication and authorization in local api angular 14
basic array questionsc++ code snippets what are the 3 basic types of plate boundaries explain their differences (how they act).
pandas column statisticshow to make a calculator in python pygame window
raylib c# basic windowsmall basic textwindow npm err! code e401 npm err! unable to authenticate, need: basic realm=https:--pkgsprodeus21.pkgs.visualstudio.com-
split a column in google sheetshow to serve html file in node.js vba check if range is empty
create route in laravel 8golang http post authentication lib in tsconfig
range recursion javascriptvbs error message how to make an exit button using vs code
how to delete a value from document in mongodbvb.net remove case sensitivity face recognition python opencv haar cascade
curl to upload to artifactoryunity simple movement script node-fetch auth
basic symbol meanings in c++visual basic variable declaration visual basic run command