Adding new repo to github from local box
PRe Req - git should be installed on your windows and you should have an account on github (https://github.com/)
download git from https://git-scm.com/download/win
and check version git --version
git config --global user.name "@hemangiXXX"
git config --global user.name ""
git config --global user.email "hemangi@XXX.com"
git config --global--list
cmd
1. git init
2. git add *.*
3. git status
4. git commit - m "Comments"
5. go to GitHub and add a new repo
6. git remote add origin https://github.com/hemangidk/smplfw.git
7. git push -u origin master
git config --global user.email "hemangihere@gmail.com"
git config --user.name "hemangidk"
------------
GIT to update the existing project repo
D:\>cd sample
D:\sample>git branch
* hk2
master
mistake_master1
D:\sample>git status
On branch hk2
Your branch is up to date with 'origin/hk2'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitignore
modified: src/test/java/com/doeex/PageFactory/FeedsPage.java
modified: src/test/java/com/doeex/PageFactory/homePage.java
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
Data/Data_1Record.xlsx
config/
selenium.txt
src/test/java/com/doeex/PageFactory/UsersPage.java
.....
no changes added to commit (use "git add" and/or "git commit -a")
D:\sample>git add *.*
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory
D:\sample>git commit -m " adding code for managed account and user management"
[hk2 023c6aa] adding code for managed account and user management
20 files changed, 1766 insertions(+), 90 deletions(-)
create mode 100644 Data/Data_1Record.xlsx
create mode 100644 config/log4j.properties
create mode 100644 selenium.txt
create mode 100644 src/test/java/com/doeex/PageFactory/UsersPage.java
....
D:\sample>git push -u origin hk2
Enumerating objects: 51, done.
Counting objects: 100% (51/51), done.
Delta compression using up to 8 threads
Compressing objects: 100% (27/27), done.
Writing objects: 100% (32/32), 22.36 KiB | 2.79 MiB/s, done.
Total 32 (delta 10), reused 0 (delta 0)
remote: Resolving deltas: 100% (10/10), completed with 9 local objects.
To https://github.com/hemangidk/sample.git
8e5ff23..023c6aa hk2 -> hk2
Branch 'hk2' set up to track remote branch 'hk2' from 'origin'.
D:\sample>git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
D:\sample>git branch
hk2
* master
mistake_master1
D:\sample>git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
ResultSummary.txt
test.logs
nothing added to commit but untracked files present (use "git add" to track)
D:\sample>git merge hk2
Updating 8e5ff23..023c6aa
Fast-forward
.gitignore | 2 +
Data/Data_1Record.xlsx | Bin 0 -> 8675 bytes
config/log4j.properties | 62 +++
selenium.txt | 398 +++++++++++++
....
D:\sample>git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
D:\sample>git commit -m "merging managed account and users code from hk2"
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
D:\sample>git push -u origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/hemangidk/sample.git
8e5ff23..023c6aa master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
D:\sample>git branch hk2
fatal: A branch named 'hk2' already exists.
D:\sample>git checkout hk2
Switched to branch 'hk2'
Your branch is up to date with 'origin/hk2'.
ref - https://www.youtube.com/watch?v=-U-eUHI6euM&list=PLhW3qG5bs-L8OlICbNX9u4MZ3rAt5c5GG
Few Addtional commands one may need
1. to create new branch
git branch <<branch name>>
ex. git branch oct24
2. to switch to new branch
D:\XXX>git checkout <<branch name>>
ex .git checkout oct24
Switched to branch 'oct24'
3. add files /modificaiton to the branch
D:\XXX>git add *.*
4. commit the changes to the branch
D:\XXX>git commit -m "adding code to branch"
5. push the changes to the branch
D:\XXX>git push -u origin oct24
------
6. See which is the current branch you are working on
git branch
D:\XXX>git branch
main
oct24
* shoct24
6 pull the changes from the branch
git pull origin <<branch Name>>
D:\XXX>git pull origin oct24