• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Simple and clear Instruction for Git and version control

Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly, you need to download Git and install it into your system:
Download Git
Choose your Operating System, and download the newest version.
Today, I used Git 2.19.1 on windows to do this.

1.      Run “Git Bash”, if you cannot find it, just search “git” in windows.
After you run it, you will see a git command line windows just like the windows command line.
First thing first, input this command to update the version to the latest one:
git clone https://github.com/git/git

Then here are some basic command line commands you will need for Git:
cd c:/some_folder/ Go to the directory after the command
cd.. Go to parent directory
cd /sub_folder Go to sub-directory

-x When you see a command followed by a “-” plus a letter, it means the arguments for the command which allows the command to perform the behavior in a different way. For example: “git push -f ” means Force to Update remote refs along with associated objects ignore warnings.

The following are some commonly used Git commands:

2.      Find the Local Repository directory (Or the directory which stores your projects), for example:
“cd C:/Users/WEI/Documents/NetBeansProjects”
*“/” is used for specifying different directories level in the command line, not “\”.
*If your directory or path includes a space, command line will not recognize it as a directory or path, type in “\” before you type space, the system will recommend you the correct one.

After you have reached the target directory, used command “git init” to initial the version control in this folder. You will find you have a new “.git” folder appears in that directory. And the directory now is called “Master”.

3. Now you have initial the git local repository, you now need to confirm and add which projects will be included in the version control.
Type in command “git cmmit -a” then “git add -A” to commit all files and folders in “master” or you can choose the one you want by giving a specific directory and file option.

4.      Now, you have the local “master” folder, but you also need an “origin” folder from an online server to store and synchronize all the changes for your projects. Many companies provide the free server for version control, GitHub is free but they will public your codes. I recommend BitBucket repository. They provide free private online repository service. Register it through the following URL: Register Bitbucket

When you have finished the registration, you should be able to create a new repository in your bitbucket dashboard page by a “+” button on the top left of the page. Then name your repository, then it turns to the repository home page. You will see a URL like https://mygitexpample@bitbucket.org/myaccount/web_projects.git which will be followed by a “.git”. This is your online repository path which also called “origin” by git.
Tap in the following command into Git Bash to set up the “origin” to Git:
git remote add origin https://mygitexpample@bitbucket.org/myaccount/web_projects.git

5.      Congratulations, you have set up all the basic things for git up and running, now you can use the command to push your files to the server.
git push -u origin master
For more specific operating on Git, please read the document.
Git Documentation

Source from YNW Web and Apps
    Bookmark Topic Watch Topic
  • New Topic