GIT create a new repository on the command line

create a new repository on the command line

echo "# mynewrepository" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/radheymishra/mynewrepository.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/radheymishra/mynewrepository.git
git push -u origin master


user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ ls
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git init
Initialized empty Git repository in /home/user/Documents/devloper1/.git/
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git clone https://github.com/radheymishra/mynewrepository.git
Cloning into 'mynewrepository'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git init
Reinitialized existing Git repository in /home/user/Documents/devloper1/.git/
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git pull -u origin master
error: unknown switch `u'
usage: git pull [<options>] [<repository> [<refspec>...]]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting

Options related to merging
    -r, --rebase[=<false|true|preserve|interactive>]
                          incorporate changes by rebasing rather than merging
    -n                    do not show a diffstat at the end of the merge
    --stat                show a diffstat at the end of the merge
    --log[=<n>]           add (at most <n>) entries from shortlog to merge commit message
    --squash              create a single commit instead of doing a merge
    --commit              perform a commit if the merge succeeds (default)
    --edit                edit message before committing
    --ff                  allow fast-forward
    --ff-only             abort if fast-forward is not possible
    --verify-signatures   verify that the named commit has a valid GPG signature
    -s, --strategy <strategy>
                          merge strategy to use
    -X, --strategy-option <option=value>
                          option for selected merge strategy
    -S, --gpg-sign[=<key-id>]
                          GPG sign commit

Options related to fetching
    --all                 fetch from all remotes
    -a, --append          append to .git/FETCH_HEAD instead of overwriting
    --upload-pack <path>  path to upload pack on remote end
    -f, --force           force overwrite of local branch
    -t, --tags            fetch all tags and associated objects
    -p, --prune           prune remote-tracking branches no longer on remote
    --recurse-submodules[=<on-demand>]
                          control recursive fetching of submodules
    -j, --jobs[=<n>]      number of submodules pulled in parallel
    --dry-run             dry run
    -k, --keep            keep downloaded pack
    --depth <depth>       deepen history of shallow clone
    --unshallow           convert to a complete repository
    --update-shallow      accept refs that update .git/shallow
    --refmap <refmap>     specify fetch refmap

user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git init
Reinitialized existing Git repository in /home/user/Documents/devloper1/.git/
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git clone https://github.com/radheymishra/mynewrepository.git
Cloning into 'mynewrepository'...
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ cd
user@user-HP-2000-Notebook-PC:~$ cd '/home/user/Documents/devloper1/mynewrepository'
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git init
Reinitialized existing Git repository in /home/user/Documents/devloper1/mynewrepository/.git/
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ ls
index.php
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ status
unity-settings-daemon start/running, process 1574
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   index.php

no changes added to commit (use "git add" and/or "git commit -a")
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git add index.php
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ gitstatus
No command 'gitstatus' found, did you mean:
 Command 'gitstats' from package 'gitstats' (universe)
gitstatus: command not found
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   index.php

user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git commit -m "speling mistak"
[master 6314606] speling mistak
 1 file changed, 1 insertion(+), 1 deletion(-)
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git push -u origin master
Username for 'https://github.com': radheymishra
Password for 'https://radheymishra@github.com':
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 282 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/radheymishra/mynewrepository.git
   ef213f9..6314606  master -> master
Branch master set up to track remote branch master from origin.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git add index.php
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/radheymishra/mynewrepository
 * branch            master     -> FETCH_HEAD
   6314606..a9a7ad5  master     -> origin/master
Updating 6314606..a9a7ad5
error: Your local changes to the following files would be overwritten by merge:
    index.php
Please, commit your changes or stash them before you can merge.
Aborting
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git commit -m "for checking merge"
[master 8a29db8] for checking merge
 1 file changed, 2 insertions(+)
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git pull origin master
From https://github.com/radheymishra/mynewrepository
 * branch            master     -> FETCH_HEAD
Auto-merging index.php
CONFLICT (content): Merge conflict in index.php
Automatic merge failed; fix conflicts and then commit the result.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ ^C
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   index.php

no changes added to commit (use "git add" and/or "git commit -a")
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   index.php

no changes added to commit (use "git add" and/or "git commit -a")
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git commit -m "merge check"
U    index.php
error: commit is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git add index.php
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git commit -m "merge check"
[master 3007360] merge check
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$ git pull origin master
From https://github.com/radheymishra/mynewrepository
 * branch            master     -> FETCH_HEAD
Already up-to-date.
user@user-HP-2000-Notebook-PC:~/Documents/devloper1/mynewrepository$


Comments

Popular posts from this blog

MySQL event scheduler and how to create MySQL events to automate database tasks

How to send Send Email with attached CSV file in codeigniter

Install Wordpress on Ubuntu 16.04