From existing project files 1- On your local project folder ex: open a terminal
$ git init
$ git add --all # in case you wish to add all the files to stage Or you can selectively add files.
$ git commit -m "Initial comment" # comment
log to your github account from web browser and Create a new repository with the same name of your project
2- copy the project url and in the terminal of your local project folder
$ git remote add origin https://github.com/<yourusername>/<myproject>.git
$ git push -u origin master
Or create a new repository from the command line
echo "# <myproject> " >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin https://github.com/<yourusername>/<myproject>.git
$ git push -u origin master
# to save user and pass
$ git config credential.helper store
$ git config --global credential.helper store
1- Fork this repository by clicking on the fork button on the top of repo page. This will create a copy of this repository in your account. Now clone the forked repository to your machine. Go to your GitHub account, open the forked repository, click on the clone button and then click the copy to clipboard icon.
1- Open a terminal and run the following git command:
$ git clone "url you just copied"
2- Change to the repository directory on your computer (if you are not already there): Now create a branch using the git checkout command:
$ git checkout -b <add-your-new-branch-name>
3- Make necessary changes and commit those changes
If you go to the project directory and execute the command
$ git status
you'll see there are changes.
Add those changes to the branch you just created using command:
$ git add mychangs.md #add
$ git add . #add all
4- Commit your changes
$ git commit -m "my modified version"
Add git repo to another with all commits
$ cd repo2
$ git checkout master
$ git remote add r1remote <url-of-repo1>
$ git fetch r1remote
$ git merge r1remote/master --allow-unrelated-histories
$ git remote rm r1remote
After that repo2/master will contain everything from repo2/master and repo1/master and will also have the history of both of them
linking repos to main repo as subfolder, to copy use subtrees
You can add repo1 as a submodule In the mainrepo repository:
$ git pull origin master #get changes if needed <!-- -->
$ git submodule add https://github.com/<user>/repo1 repo1
You can use a modified clone command to ensure you download everything, including any submodules:
$ git clone --recursive <project url>
for more : https://github.blog/2016-02-01-working-with-submodules/
you can clone specific branch without need to merge it with the repo master by:
$ git clone -b <branch> <remote_repo>
ex: $ git clone -b betabot https://github.com/Geekgineer/ros-web-gui.git
$ git config --global user.email "myemail"
$ git config --global user.name "myusername"
$ git reset HEAD
$ git pull
then add/commit/push as usual