How to commit code to GitHub on Android through termux app - github

Please I would appreciate if anyone can drop a direct link to the termux commands used to create repos,commit code and delete them on GitHub through termux terminal,all I have seen through numerous Google searches are only how to install them,I also don't know how to navigate to a certain file or directory.

First of all you have to install git in termux pkg install git . then go to the directory where your code have with cd <name of your directory>
If you want to create a git repository use git init.
then add the files to git
git add <file name> OR add all files in the directory git add .
First commit after installing git you have to specify who you are
git config --global user.name "<Your Name>"
git config --global user.email "<your_email#whatever.com>"
then commit the code with
git commit -m "<commit message>"
commit message is what changes you done in this commit
you have to create a reposityory in github github.com/new
and add github reposityory url to git git remote add origin https://github.com/<github username>/<github repository name>.git
then push the repository to github. git push -u origin master
-u means seting upstream as default. after that just git push
have some reference of tutorials about git
learnxinyminutes, githowto

Related

Git push creates my project folder inside another folder, how to avoid it?

I have been creating some repositories of my projects since the terminal and everything was good, but recently I tried to push a project to GitHub and but another folders are created.
For example, the path of my project folder is /Desktop/Programming_course/React_Native/robotreact.
So, since the terminal I go to the path of my Project robotreact and I run:
git add .
git commit -m "first commit"
Then, in GitHub, I create my repository and after that I run:
git remote add origin https://github.com/Josesosa0777/robotreact.git
when I push it running: git push -u origin main
In my GitHub are created other folders:
How can I avoid those extra folders?
It seems like if another project is added, I am not sure if the problem is about a SSH key, I dont know how to solve it, any idea?
That means you have initialized your Git repository in / instead of /Desktop/Programming_course/React_Native/robotreact: check for /.git
If that is the case, and you don't have many commits, you can simply:
delete /.git
initialize the repository in the right folder,
add the remote origin
add files, commit and push
That is:
cd /Desktop/Programming_course/React_Native/robotreact
git init .
git remote add origin https://github.com/Josesosa0777/robotreact.git
# check your user.name/user.email
git config user.name
git config user.email
git add .
git commit -m "First import"
git push -u origin main
If your local branch is master:
git push -u origin master:main

How to push changes to old repo to GITHUB after downloading it

I lost my PC data after hard-drive corruption. After that from my github repo i downloaded my code and made some changes and did npm install, but when i tried to push my changes to repo, it is saying there are no currently active repo to push.
How to push my new changes to my old repo?
You should have cloned the repo on your local machine, that way you would have the git initialized. But, for now, you can follow the below steps.
git init
git remote add origin <github repo url>
The first line would initialize the git repo and the second would point it to the online repo you already have.
You could have downloaded the repo with:
git clone <repo url>
but to answer your question:
git init
git add .
git commit -m "init"
git remote add origin <repo url>
you can then verify the remote url with:
git remote -v
after that check If your .gitignore file is there, if not create one and add node_modules/
after that just push it with:
git push -f origin master
just check whether you have set the remote origin correctly.
$ git remote show origin
$ git remote -v
use the above commands to check your remote URL. if it is not set correctly, set the URL again.
$ git remote set-url < your repo URL here >
hope this will work

How to update code in gitlab

My team committed code to gitlab repository and I need to take those updates. I already clone the project into my local directory but didn't take update before.
For taking update what commands need to run. I already tried pull command and it shows the changed file details but that changes are not applying to the project. For apply the changes any new command needs to run again?
Run following commands for taking the update:
git fetch && git checkout master
git pull
git config --global user.name "demo"
git config --global user.email "demo#gmail.com"
Create a new repository:
git clone https://gitlab.com/demo_test.git
cd demo_test
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Push an existing folder:
cd existing_folder
git init --initial-branch=main
git remote add origin https://gitlab.com/demo_test.git
git add .
git commit -m "Initial commit"
git push -u origin main
Push an existing Git repository:
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/demo_test.git
git push -u origin --all
git push -u origin --tags

How to push eclipse workspace projects to git using GIT CMD desktop application?

I would like to synchronize all my eclipse workspace to a github repository. Please tell me the list of commands to do it.
To access Git commands from CMD. You have to set the PATH Environment Variables to Git's bin directory, mine is C:\Program Files\Git\bin.
Then configure your information for all local repo
git config --global user.name "[name]"
git config --global user.email "[email address]"
Create your repository on GitHub. Then go to your project directory(eclipse workspace projects) git init [project-name] and add all files to staging area git add --all or git add * Then commit it with some message git commit -m “Initial Commit” and then git remote add origin <url> then push your files to GitHub git push origin master
See this GIT CHEAT SHEET to know more...
Updated :
Here is the link to download GIT Cheat Sheet PDF.
Take a look !
GIT CHEAT SHEET
If you cloned your Eclipse workspace from a GitHub repository, all you need to do is
git push origin master
If you didn't, you first need to create an empty repository on GitHub. Then copy and paste the URL at the top of the page for your new repo. From the command line type
git remote add origin <paste URL here>
Now you can use the same git push command as above to push your git history to the new GitHub repo.

branching a git repository

I have been given access to a git repository. I would like to create a new branch to the existing code. I am unable to find proper steps online to do this process. I believe i should first setup the master in git bash and then create a branch. If anyone can give me the sequence of steps to be followed, that would be helpful.
First step is, creating the clone of the remote branch
git clone <git repo> <folder_name>
example:
$ git clone git://git.kernel.org/abc my2.6
change directory to the newly formed directory ie my2.6
$ cd my2.6
Creating a new branch
git branch <branch name>
$ git branch my2.6.14
Go to new branch:
git checkout <branch name>
example:
$ git checkout my2.6.14
The git pro book is a great source to find information and learning about git: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging.
First make sure you have cloned the git repository using git clone command. After that you can check the current branch with this command: git branch
You can create new branch using this command: git checkout -b mybranch