Wednesday 22 September 2021

git repository - git commands

git steps:

git pull --rebase   # to pull the latest code from git

git pull --rebase  # again doing the same .. just for conformation  [optional]

Already up to date.

git status

git add <1st file name along with path>

git add <2nd file name along with path>

git add <3rd file name along with path>

# or you can add all files at once by using git add . command

git status

 git commit -m " you can provide the message "

git push origin HEAD:refs/for/project-int

open git link then add reviewers (who can review your code)

==============================================================

How do you enter into a particular branch & test? how do come out of that branch again?

git branch (cmd will be used to check your current branch=> note down somewhere Ex: * master)

git checkout <brach_name_need_to_test>

git branch ==> cmd will be used to check your current branch, have you moved or not? 

Do your testing 

git checkout <master>

git branch 

==============================================================

How do I check multiple previous git commit changes?

git log (type this command in the git bash prompt, and it will display as below )

commit id (HEAD -> Branch_name)

Author: Narendra <EMPID@companyname>

Date:   Fri Sep 17 11:38:40 2021 +0530

    latest changes in input file & added chamber details in file_name.py

Press the down arrow  mark (arrow  mark ) then you can see all previous commit changes datewise

Press q for quit from the log 

==============================================================

                                           In real-time I have faced the following git related issues:

In the latest git code, if you modify code in a single file or multiple files when you have given git status, it will display that file change.

if you don't want that file changed then 

git restore <filename along with path>

git status

==============================================================

When  you have committed and pushed your code to git, but you don't want to do that  then you have to follow the below procedure

git log (type this command in the git bash prompt, and it will display as below )

commit id (HEAD -> Branch_name)

Author: Narendra <EMPID@companyname>

Date:   Fri Sep 17 11:38:40 2021 +0530

    latest changes in input file & added chamber details in file_name.py

Press q for quit from the log

git reset --hard origin/<branch>

git pull origin fusion-int --rebase

git status

after this, you can pull the latest code if you want by typing the below command.

git pull --rebase

==============================================================

==============================================================

==============================================================





No comments:

Post a Comment