Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
  • repo -> repository

  • clone -> bring a repo down from the internet (remote repository like Github) to your local machine

  • add -> track your files and changes with Git

  • commit -> save your changes into Git

  • push -> push your changes to your remote repo on Github (or another website)

  • pull -> pull changes down from the remote repo to your local machine

  • status -> check to see which files are being tracked or need to be commited

  • init -> use this command inside of your project to turn it into a Git repository and start using Git with that codebase

@Villelmo
Copy link

Villelmo commented Dec 10, 2020

Are those a principal command?

@Sushant333
Copy link

Sushant333 commented Dec 22, 2020

                                                        TOP GITHUB COMMANDS
  1. git config –global user.name “[name]” ->sets author name
    git config –global user.email “[email address]” ->sets author email id

  2. git init [repository name] ->start new repository

  3. git clone [url] ->obtain a repository from an existing URL.

  4. git add [file] ->adds a file to the staging area.

  5. git commit -m “[ Type in the commit message]” ->records or snapshots the file permanently in the version history.
    git commit -a ->commits any files you’ve changed since then.&commits any files you’ve added

  6. git diff ->shows the file differences which are not yet staged.
    git diff –staged ->differences between the files in the staging area and the latest version present.
    git diff [first branch] [second branch] ->differences between the two branches mentioned.

  7. git reset [file] ->unstages the file, but it preserves the file contents.
    git reset [commit] ->undoes all the commits after the specified commit and preserves the changes locally.
    git reset –hard [commit] ->discards all history and goes back to the specified commit.

  8. git status ->command lists all the files that have to be committed.

9 ) git rm [file] ->deletes the file from your working directory and stages the deletion.

  1. git log ->used to list the version history for the current branch.
    git log –follow[file] ->lists version history for a file, including the renaming of files also.

  2. git show [commit] ->shows the metadata and content changes of the specified commit.

  3. git tag [commitID] ->used to give tags to the specified commit.

  4. git branch ->lists all the local branches in the current repository.
    git branch [branch name] -> creates a new branch.
    git branch -d [branch name] -> deletes the feature branch.

  5. git checkout [branch name] -> used to switch from one branch to another
    git checkout -b [branch name] ->creates a new branch and also switches to it.

  6. git merge [branch name] ->merges the specified branch’s history into the current branch.

  7. git remote add [variable name] [Remote Server Link] ->used to connect your local repository to the remote server.

  8. git push [variable name] master ->sends the committed changes of master branch to your remote repository.
    git push [variable name] [branch] ->sends the branch commits to your remote repository.
    git push –all [variable name] ->pushes all branches to your remote repository.
    git push [variable name] :[branch name] ->deletes a branch on your remote repository.

  9. git pull [Repository Link] ->fetches and merges changes on the remote server to your working directory.

  10. git stash save ->stores all the modified tracked files.

  11. git stash pop ->restores the most recently stashed files.
    git stash list ->lists all stashed changesets.
    git stash drop ->discards the most recently stashed changeset.

@Fabaladibbasey
Copy link

Fabaladibbasey commented Feb 6, 2021

git checkout -b [name of the branch] -> to create a new branch
git checkout [name of the branch] -> to navigate into the named branch
git checkout -d [name of the branch] -> to delete the branch
git merge [branch name] -> to merge the branch to current branch in working directory

@diejel
Copy link

diejel commented Apr 8, 2021

Thank you @Sushant333

@ZivGrinblat
Copy link

ZivGrinblat commented May 1, 2021

Thank you for this guide, it is so helpful!

@nrimawi
Copy link

nrimawi commented Jul 6, 2021

Thank you @Sushant333

@Cr7mlc
Copy link

Cr7mlc commented Aug 20, 2021

@great-analyzer
Copy link

great-analyzer commented Sep 29, 2021

This link was mentioned in https://www.youtube.com/watch?v=RGOj5yH7evk. I don't think it makes much sense if not directed from that link.

@FlashAmarillo
Copy link

FlashAmarillo commented Nov 3, 2021

This is awesome and helpful, Thanks Gwen

@abdulbasit1995
Copy link

abdulbasit1995 commented Nov 3, 2021

                                                        TOP GITHUB COMMANDS
  1. git config –global user.name “[name]” ->sets author name
    git config –global user.email “[email address]” ->sets author email id
  2. git init [repository name] ->start new repository
  3. git clone [url] ->obtain a repository from an existing URL.
  4. git add [file] ->adds a file to the staging area.
  5. git commit -m “[ Type in the commit message]” ->records or snapshots the file permanently in the version history.
    git commit -a ->commits any files you’ve changed since then.&commits any files you’ve added
  6. git diff ->shows the file differences which are not yet staged.
    git diff –staged ->differences between the files in the staging area and the latest version present.
    git diff [first branch] [second branch] ->differences between the two branches mentioned.
  7. git reset [file] ->unstages the file, but it preserves the file contents.
    git reset [commit] ->undoes all the commits after the specified commit and preserves the changes locally.
    git reset –hard [commit] ->discards all history and goes back to the specified commit.
  8. git status ->command lists all the files that have to be committed.

9 ) git rm [file] ->deletes the file from your working directory and stages the deletion.

  1. git log ->used to list the version history for the current branch.
    git log –follow[file] ->lists version history for a file, including the renaming of files also.
  2. git show [commit] ->shows the metadata and content changes of the specified commit.
  3. git tag [commitID] ->used to give tags to the specified commit.
  4. git branch ->lists all the local branches in the current repository.
    git branch [branch name] -> creates a new branch.
    git branch -d [branch name] -> deletes the feature branch.
  5. git checkout [branch name] -> used to switch from one branch to another
    git checkout -b [branch name] ->creates a new branch and also switches to it.
  6. git merge [branch name] ->merges the specified branch’s history into the current branch.
  7. git remote add [variable name] [Remote Server Link] ->used to connect your local repository to the remote server.
  8. git push [variable name] master ->sends the committed changes of master branch to your remote repository.
    git push [variable name] [branch] ->sends the branch commits to your remote repository.
    git push –all [variable name] ->pushes all branches to your remote repository.
    git push [variable name] :[branch name] ->deletes a branch on your remote repository.
  9. git pull [Repository Link] ->fetches and merges changes on the remote server to your working directory.
  10. git stash save ->stores all the modified tracked files.
  11. git stash pop ->restores the most recently stashed files.
    git stash list ->lists all stashed changesets.
    git stash drop ->discards the most recently stashed changeset.

What a cool list of commands. Thank you for it.

@framogaza
Copy link

framogaza commented Dec 29, 2021

Thanks!

@islombeknematov
Copy link

islombeknematov commented Jan 29, 2022

That's awesome, thanks a lot

@ZainabAlotaibi
Copy link

ZainabAlotaibi commented Feb 6, 2022

Very helpful. Thank you

@NourEssalam
Copy link

NourEssalam commented Mar 29, 2022

thanks dude that's helped me a lot

@Dvip07
Copy link

Dvip07 commented Apr 10, 2022

Thank you so much for this.

@sanjeebtiwary
Copy link

sanjeebtiwary commented Apr 10, 2022

thanks dude that's helped me a lot

@Ubaidullahqureshi
Copy link

Ubaidullahqureshi commented Apr 15, 2022

Thanks

@sabuein
Copy link

sabuein commented Apr 29, 2022

Thank you, everyone.

@BertinAm
Copy link

BertinAm commented Jun 11, 2022

git checkout 'branch-name' -> helps to switch between branches locally
git branch -d 'branch-name' -> helps to delete branches locally
git checkout -b 'branch-name' -> helps to create a new branch locally
git merge 'branch-name' -> helps to merge branches together locally

@ayish1998
Copy link

ayish1998 commented Jun 13, 2022

So after generating the ssh key? How do I display them on the Git Bash command? I need help on that please. I have used various prompt but it still not showing

@BertinAm
Copy link

BertinAm commented Jun 13, 2022

okay to display the ssh key you use "cat key_name.pub"

@BertinAm
Copy link

BertinAm commented Jun 13, 2022

hope that was helpful

@ayish1998
Copy link

ayish1998 commented Jun 14, 2022

@BertinAm it did not work. The pop up "No such file or directory"

@BertinAm
Copy link

BertinAm commented Jun 14, 2022

ill run you through the commands to create your private and public ssh keys
-ssh-keygen -t rsa -b 4096 -C "email@example.com" // to create your set of keys both public and private key and save it into a file
-vim ~/.ssh/config // to open up the file you created which contains the keys
-[ Host *
AddKeysToAgent yes
UserKeychain yes
IdentityFile ~/.ssh/id_rsa ] // paste this line of code in the [ ] in the file you create after executing the vim ~/.ssh/config command

  • ls | grep gitkey // to display the keys created
  • cat key_name // to display the content of any key created
  • ssh-agent -s // to start the ssh-agent in the background
  • vim ~/.ssh/config // to configure the created file which contains the keys
  • ssh-add -K ~/.ssh/private_key_name // to add the private key to the ssh agent
    The above commands should help you setup your ssh keys properly
    @ayish1998 hope this was helpful

@ayish1998
Copy link

ayish1998 commented Jun 14, 2022

let me try this process

@BertinAm
Copy link

BertinAm commented Jun 14, 2022

okay

@ayish1998
Copy link

ayish1998 commented Jun 14, 2022

@BertinAm Does this works on windows as well?

@BertinAm
Copy link

BertinAm commented Jun 14, 2022

i haven't tried it on windows but you coud lookup how to install vim on command prompt and then follow it from there on and also how to run ssh commands too. For one final strategy try installing git bash and running the commands there.

@ayish1998
Copy link

ayish1998 commented Jun 14, 2022

Okay cool
Thanks

@BertinAm
Copy link

BertinAm commented Jun 14, 2022

your welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment