Installation (Detailed information)
sudo apt-get update
sudo apt-get install git
sudo yum install git
https://git-scm.com/download/linux
Windows(7 or later) - https://github.com/git-for-windows/git/releases/
git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"
git config --list
Initialize your repository on your local machine -
git init
git remote add origin <repo_url.git>
or
git clone <repo_url.git>
Create an html file (index.html) -
<html>
<head>
<title>
First contribution!
</title>
</head>
<body>
<h1> C-Cube </h1>
<h2>Learn.Join.Compete.</h2>
</body>
</html>
Create an blog file (blog.html) -
<html>
<head>
<title>
Daily Blog
</title>
</head>
<body>
<div> <h1>An awesome Monday!</h1> //title
<h4>- C-Cube</h4> //author
<p> What a contradictory title! :P </p> //body
</div>
</body>
</html>
git status
(use whenever in doubt about the status of the files)
git add <file>
(track the files)
git commit -m "some relevant message"
(commit the files)
git push origin master
(Push master branch to origin)
Add.Commit.Push.
These are the three git commands that will be used heavily. Keep them handy!
git branch
(List out the available branches)
git branch <branch_name>
(Why do we need branches? What happens after branching?)
git checkout <branch_name>
(Switch branches)
After 'gitting it'..
- Github (Compare and Pull Request)
- Command line -
After committing
git checkout master
git merge <branch_name>
And then push master to origin.
What is gitignore and why is it important?
<<<<<<< HEAD
Code that you have written
=======
Your friend's code
>>>>>>> 90e9cff27a42949307694d35d5ea5138e2d11a1a
git clone <repo_url.git>
Make a new branch (good practice)
Make awesome changes
Add.Commit.Push.
Create a pull request.
Wait.Review.Push.Enjoy!
git clone https://github.com/my-username/how-to-git.git
cd how-to-git
git checkout -b my-branch
git remote add howtogit https://github.com/nirajpandkar/how-to-git.git
###Check the new added remote
git remote -v
###Fetch the latest version of master
git fetch howtogit
git rebase howtogit/master
You may get conflicts. After resolving those conflicts Add.Commit.
Wait.. No Push.?
Yes. Here you first git rebase --continue
Note: If --continue
isn't working use the --skip
flag for now!
And then git push -f origin master
(-f for force push)
Your pull request will be updated!! Successfully rebased!
SVN
remote
local
origin
master
commit
track
branches
gitignore
rebase