Labels

Thursday, 27 April 2017

HOW TO CREATE A GIT HUB ACCOUNT with terminal help

26.04.2017

HOW TO CREATE A Git Hub ACCOUNT


  • Step 0: Install git and create a GitHub account 

The first two things you'll want to do are install git and create a free GitHub account.



  • Step 1: Create a local git repository 

     

When creating a new project on your local machine using git, you'll first create a new repository (or often, 'repo', for short).


To begin, open up a terminal and move to where you want to place the project on your local machine using the cd (change directory) command. For example, if you have a 'projects' folder on your desktop, you'd do something like:


mnelson:Desktop mnelson$ cd ~/Desktop
mnelson:Desktop mnelson$ mkdir myproject
mnelson:Desktop mnelson$ cd myproject/

To initialize a git repository in the root of the folder, run the git init command:


mnelson:myproject mnelson$ git init
Initialized empty Git repository in /Users/mnelson/Desktop/myproject/.git/

  • Step 2: Add a new file to the repo

Go ahead and add a new file to the project, using any text editor you like or running a touch command.

Once you've added or modified files in a folder containing a git repo, git will notice that changes have been made inside the repo. But, git won't officially keep track of the file (that is, put it in a commit - we'll talk more about commits next) unless you explicitly tell it to.



mnelson:myproject mnelson$ touch mnelson.txt
mnelson:myproject mnelson$ ls
mnelson.txt




After creating the new file, you can use the git status command to see which files git knows exist.


mnelson:myproject mnelson$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

 mnelson.txt

nothing added to commit but untracked files present (use "git add" to track)
 
  • Step 3: Add a file to the staging environment


Add a file to the staging environment using the git add command. 


If you rerun the git status command, you'll see that git has 
added the file to the staging environment (notice the "Changes to be 
committed" line).  


    

mnelson:myproject mnelson$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

 new file:   mnelson.txt 
  • Step 4: Create a commit

     

It's time to create your first commit!
Run the command git commit -m "Your message about the commit"
mnelson:myproject mnelson$ git commit -m "This is my first commit!"

[master (root-commit) b345d9a] This is my first commit!
 1 file changed, 1 insertion(+)
 create mode 100644 mnelson.txt
 
  • Step 5: Create a new branch

     

Now that you've made a new commit, let's try something a little more advanced.
mnelson:myproject mnelson$ git branch
  master
* my-new-branch 
 
 
  • Step 6: Create a new repository on GitHub

If you only want to keep track of your code locally, you don't need to use GitHub. But if you want to work with a team, you can use GitHub to collaboratively modify the project's code.
To create a new repo on GitHub, log in and go to the GitHub home page.You should see a green '+ New repository' button:
After clicking the button, GitHub will ask you to name your repo and provide a brief description:

mnelson:myproject mnelson$ git remote add origin https://github.com/cubeton/mynewrepository.git
mnelson:myproject mnelson$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 263 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/cubeton/mynewrepository.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
 

  •  Step 7: Push a branch to GitHub

Now we'll push the commit in your branch to your new GitHub repo. This allows other people to see the changes you've made. If they're approved by the repository's owner, the changes can then be merged into the master branch.
To push changes onto a new branch on GitHub, you'll want to run git push origin yourbranchname. GitHub will automatically create the branch for you on the remote repository: 
mnelson:myproject mnelson$ git push origin my-new-branch

Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/cubeton/mynewrepository.git
 * [new branch]      my-new-branch -> my-new-branch
 
If you refresh the GitHub page, you'll see note saying a branch with 
your name has just been pushed into the repository. You can also click 
the 'branches' link to see your branch listed there.
 
 
 
  • Step 8: Create a Pull Request (PR)

A pull request (or PR) is a way to alert a repo's owners that you want to make some changes to their code. It allows them to review the code and make sure it looks good before putting your changes on the master branch.
This is what the PR page looks like before you've submitted it:
And this is what it looks like once you've submitted the PR request:
You might see a big green button at the bottom that says 'Merge pull request'. Clicking this means you'll merge your changes into the master branch. 
  • Step 9: Merge a PR

Go ahead and click the green 'Merge pull request' button. This will merge your changes into the master branch.
 
You can double check that your commits were merged by clicking on the 'Commits' link on the first page of your new repo.
This will show you a list of all the commits in that branch. You can see the one I just merged right up top (Merge pull request #2).

Step 10: Get changes on GitHub back to your computer

Right now, the repo on GitHub looks a little different than what you have on your local machine. For example, the commit you made in your branch and merged into the master branch doesn't exist in the master branch on your local machine.
In order to get the most recent changes that you or others have merged on GitHub,
use the git pull origin master command (when working on the master branch).
mnelson:myproject mnelson$ git pull origin master

remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/cubeton/mynewrepository
 * branch            master     -> FETCH_HEAD
   b345d9a..5381b7c  master     -> origin/master
Merge made by the 'recursive' strategy.
 mnelson.txt | 1 +
 1 file changed, 1 insertion(+) aaaa
This shows you all the files that have changed and how they've changed.
Now we can use the git log command again to see all new commits.
(You may need to switch branches back to the master branch.
You can do that using the git checkout master command.)
mnelson:myproject mnelson$ git log

commit 3e270876db0e5ffd3e9bfc5edede89b64b83812c
Merge: 4f1cb17 5381b7c
Author: Meghan Nelson <mnelson@hubspot.com>
Date:   Fri Sep 11 17:48:11 2015 -0400

    Merge branch 'master' of https://github.com/cubeton/mynewrepository

commit 4f1cb1798b6e6890da797f98383e6337df577c2a
Author: Meghan Nelson <mnelson@hubspot.com>
Date:   Fri Sep 11 17:48:00 2015 -0400

    added a new file

commit 5381b7c53212ca92151c743b4ed7dde07d9be3ce
Merge: b345d9a 1e8dc08
Author: Meghan Nelson <meghan@meghan.net>
Date:   Fri Sep 11 17:43:22 2015 -0400

    Merge pull request #2 from cubeton/my-newbranch
    
    Added some more text to my file

commit 1e8dc0830b4db8c93efd80479ea886264768520c
Author: Meghan Nelson <mnelson@hubspot.com>
Date:   Fri Sep 11 17:06:05 2015 -0400

    Added some more text to my file

commit b345d9a25353037afdeaa9fcaf9f330effd157f1
Author: Meghan Nelson <mnelson@hubspot.com>
Date:   Thu Sep 10 17:42:15 2015 -0400

    This is my first commit!
 
 
-THANKS UKI- 

2 comments:

Last day at Uki

Before Uki, I don’t know the fact that coding is like an ocean. Because I studied HTML and CSS only. I had some weaknesses like stage f...

Popular posts