Skip to content

Instantly share code, notes, and snippets.

@amitmerchant1990
Last active July 23, 2019 22:27
Show Gist options
  • Save amitmerchant1990/8861044 to your computer and use it in GitHub Desktop.
Save amitmerchant1990/8861044 to your computer and use it in GitHub Desktop.
Setup a brand new repo on Git
1) Configure your user and email for Git via the following command.
  • configure the user which will be used by git

  • Of course you should use your name

    git config --global user.name "Example Surname"

  • Same for the email address

    git config --global user.email "your.email@gmail.com"

2) Push configuration
  • set default so that all changes are always pushed to the repository

    git config --global push.default "matching"

3) Avoid merge commits for pulling
  • set default so that you avoid unnecessary commits

    git config --global branch.autosetuprebase always

4) Color Highlighting
> git config --global color.ui true
> git config --global color.status auto
> git config --global color.branch auto
5) Query existing global Git settings
> git config --list
6) Then go to the folder which you want to add on the repository. And fire below command:
  • Initialize the Git repository
  • for the current directory

    git init

7) Status of the repository
> git status
8) Add files to Git index
  • add all files to the index of the
  • Git repository

    git add .

9) Commit to Git repository
  • commit your file to the local repository

    git commit -m "Initial commit"

10) Show Log
  • show the Git log for the change

    git log

11) Create the remote repository, and get the URL such as git://github.com/youruser/somename.git
12) to attach your remote repo with the name 'origin' (like cloning would do)
> git remote add origin [URL From Step 11]
13) to push up your master branch (change master to something else for a different branch):
> git push origin master

Steps to follow for commiting regular changes

1) Add all the files which are changed:
> git add <specify files here>
2) Commit all the added files
> git commit -m "commit status"
3) Push all the commited changes to Git
> git push origin master

That's all!

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